From def2bdd9a6f2d6bb81423f1e5bf91f74dad2e753 Mon Sep 17 00:00:00 2001 From: coderkind Date: Tue, 7 Aug 2018 13:59:44 +0100 Subject: [PATCH 1/6] Add test for stringified hash --- spec/crimp_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/crimp_spec.rb b/spec/crimp_spec.rb index bb96378..314a290 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,12 @@ end end + context 'given a stringified hash' do + it 'returns MD5 hash of stringified hash' do + 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 } From ff2542fd278cb0dbef3f47065fc46f4e1bd2d536 Mon Sep 17 00:00:00 2001 From: coderkind Date: Tue, 7 Aug 2018 15:44:33 +0100 Subject: [PATCH 2/6] Add stringified hash MD5 test --- .bundle/config | 2 ++ spec/App.js | 29 +++++++++++++++++++++++++++++ spec/consistency_spec.rb | 7 +++++++ spec/crimp_spec.rb | 3 +++ 4 files changed, 41 insertions(+) create mode 100644 .bundle/config create mode 100644 spec/App.js diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000..04b6d71 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_JOBS: 3 diff --git a/spec/App.js b/spec/App.js new file mode 100644 index 0000000..f29f437 --- /dev/null +++ b/spec/App.js @@ -0,0 +1,29 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import Header from './components/Header'; +import PidForm from './components/PidForm'; +class App extends React.Component { + // state = { + // pid: '', + // vpid: '' + // }; + + render() { + return ( +
+
+ +
+ ); + } +} +// const App = () => { +// return ( +//
+//
+// +//
+// ); +// }; +export default App; +ReactDOM.render(, document.getElementById('app')); diff --git a/spec/consistency_spec.rb b/spec/consistency_spec.rb index 9bb60a9..8fe343a 100644 --- a/spec/consistency_spec.rb +++ b/spec/consistency_spec.rb @@ -39,6 +39,13 @@ 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 end end end diff --git a/spec/crimp_spec.rb b/spec/crimp_spec.rb index 314a290..8c80591 100644 --- a/spec/crimp_spec.rb +++ b/spec/crimp_spec.rb @@ -26,7 +26,10 @@ 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 From ac5878e4f97b4f85548396256299f6a5d9666544 Mon Sep 17 00:00:00 2001 From: coderkind Date: Tue, 7 Aug 2018 16:30:59 +0100 Subject: [PATCH 3/6] Add MD5 string test --- spec/consistency_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/consistency_spec.rb b/spec/consistency_spec.rb index 8fe343a..2bfc444 100644 --- a/spec/consistency_spec.rb +++ b/spec/consistency_spec.rb @@ -46,6 +46,13 @@ 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 end end end From afc43ed39bdb4ff3ba7a85829bf358bc9abae9ef Mon Sep 17 00:00:00 2001 From: coderkind Date: Tue, 7 Aug 2018 16:32:34 +0100 Subject: [PATCH 4/6] Remove file added in error --- .bundle/config | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .bundle/config diff --git a/.bundle/config b/.bundle/config deleted file mode 100644 index 04b6d71..0000000 --- a/.bundle/config +++ /dev/null @@ -1,2 +0,0 @@ ---- -BUNDLE_JOBS: 3 From b597592ed873b1aa88b0000e6ce0c891145a8b9e Mon Sep 17 00:00:00 2001 From: coderkind Date: Tue, 7 Aug 2018 16:42:50 +0100 Subject: [PATCH 5/6] Remove file added in error --- spec/App.js | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 spec/App.js diff --git a/spec/App.js b/spec/App.js deleted file mode 100644 index f29f437..0000000 --- a/spec/App.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import Header from './components/Header'; -import PidForm from './components/PidForm'; -class App extends React.Component { - // state = { - // pid: '', - // vpid: '' - // }; - - render() { - return ( -
-
- -
- ); - } -} -// const App = () => { -// return ( -//
-//
-// -//
-// ); -// }; -export default App; -ReactDOM.render(, document.getElementById('app')); From b0976d68e3c403fa3b94ef03aebc119f92483067 Mon Sep 17 00:00:00 2001 From: coderkind Date: Tue, 7 Aug 2018 16:56:02 +0100 Subject: [PATCH 6/6] Add number-based test --- spec/consistency_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/consistency_spec.rb b/spec/consistency_spec.rb index 2bfc444..4e72d72 100644 --- a/spec/consistency_spec.rb +++ b/spec/consistency_spec.rb @@ -53,6 +53,15 @@ 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