sam-b / HashData

A command line Hash Identifying tool.
https://rubygems.org/gems/hashdata
MIT License
100 stars 22 forks source link

Set up a spec suit #4

Open ghost opened 10 years ago

ghost commented 10 years ago

It would be useful to have some kind of spec/test suit, preferably with RSpec (my favourite), to test whether each hash is recognized as expected.

sam-b commented 10 years ago

Definitely a good idea - shall look into it tomorrow.

ghost commented 10 years ago

I can write it all up if I have all the necessary hashes so I can test whether the library recognizes them in the right way. I was thinking of something simple like:

describe HashChecker
  it 'recognizes a xxx hash' do
    HashChecker.new.check('xxx').should eq('yyy')
  end
end
ghost commented 10 years ago

Instead of testing the actual command line app and thus output, we could add some kind of ID, like a symbol, to the end of each pattern in hash_data.rb, and make that file only handle the patterns instead of concatenating them into a human-readable form. The hashdata executable file should handle that sort of stuff instead. That way, we can just test the API instead of the CLI.

sam-b commented 10 years ago

Sorry I forgot about this, its been a hectic month - not sure about separating the naming and the patterns, one of the original goals of this was to also make it easy for people to get regexs for hash functions to use for other projects, since I couldn't find anything offering them previously.

ghost commented 10 years ago

Oh, no that's not what I meant. I just wanted some way of ID-ing each regular expression so we know the correct one was matched when testing. I don't necessarily mean separating these into various documents and certainly not separating the names from the regular expression.

sam-b commented 10 years ago

Adding a "verify" function that takes a hash name and verifies the supplied hash if potentially of that type seems like an easier way to do this. On the plus this also provides a valid reason to use hashdata as a library. I can see use cases for verifying a hash type in other programs but spitting out a list of hash types is really only going to be useful as a command line util.

ghost commented 10 years ago

I :+1: this approach.

sam-b commented 10 years ago

The library functionality was expanded and the first rspec test case created in commit b01c41084b4e64ae252ba5a69c43f786680174ed I shall continue to expand the hashes covered periodically - finding the hashes is bordering on a treasure hunt because a lot of them are from certain frameworks/OSs etc. So the plan is tag them all with source example code/commands and versions (I missed versions on the first upload shall add imminently).