HashData icon indicating copy to clipboard operation
HashData copied to clipboard

Set up a spec suit

Open ghost opened this issue 12 years ago • 8 comments

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.

ghost avatar Jan 03 '14 10:01 ghost

Definitely a good idea - shall look into it tomorrow.

sam-b avatar Jan 03 '14 18:01 sam-b

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 avatar Jan 03 '14 18:01 ghost

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.

ghost avatar Feb 03 '14 16:02 ghost

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.

sam-b avatar Feb 03 '14 19:02 sam-b

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.

ghost avatar Feb 03 '14 19:02 ghost

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.

sam-b avatar Feb 03 '14 23:02 sam-b

I :+1: this approach.

ghost avatar Feb 04 '14 13:02 ghost

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).

sam-b avatar Feb 23 '14 17:02 sam-b