diff --git a/spec/consistency_spec.rb b/spec/consistency_spec.rb index 9bb60a9..4e72d72 100644 --- a/spec/consistency_spec.rb +++ b/spec/consistency_spec.rb @@ -39,6 +39,29 @@ specify { expect(subject.signature(array)).to eq md5 } end + + context 'given stringified hash' do + let(:stringified_hash) {"{ a: { b: 'b', c: 'c' }, d: 'd' }"} + let(:md5) { 'f5327912eeb41996b5aded6550d11187' } + + specify { expect(subject.signature(stringified_hash)).to eq md5 } + end + + context 'given a string' do + let(:string) {"do shash'owania"} + let(:md5) { '48e380a165c417253512a904d6b5cf2b' } + + specify { expect(subject.signature(string)).to eq md5 } + end + + context 'given a number' do + let(:number) {1234567890} + # RUBY 2.5.0 + # let(:md5) { 'cbabd6f8bfda13b76c0e28eb0a6f4ef1' } + let(:md5) { '1f5c62f597aefd84d180c26e1de61021' } + + specify { expect(subject.signature(number)).to eq md5 } + end end end end diff --git a/spec/crimp_spec.rb b/spec/crimp_spec.rb index bb96378..8c80591 100644 --- a/spec/crimp_spec.rb +++ b/spec/crimp_spec.rb @@ -3,6 +3,7 @@ describe Crimp do let (:hash) { { a: { b: 'b', c: 'c' }, d: 'd' } } let (:hash_unordered) { { d: 'd', a: { c: 'c', b: 'b' } } } + let (:stringified_hash) {"{ a: { b: 'b', c: 'c' }, d: 'd' }"} let (:array) { [1, 2, 3, [4, [5, 6]]] } let (:array_unordered) { [3, 2, 1, [[5, 6], 4]] } @@ -24,6 +25,15 @@ end end + context 'given a stringified hash' do + specify { expect(subject.signature(stringified_hash)).to be_a String } + + it 'returns MD5 hash of stringified hash' do + # puts subject.signature(stringified_hash) + expect(subject.signature(stringified_hash)).to eq(Digest::MD5.hexdigest(subject.stringify(stringified_hash))) + end + end + context 'given an Array' do specify { expect(subject.signature(array)).to be_a String }