hashes_equal 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 592e8dd71868e0562bc22597481fe2976e66a1d98736b226b5081888845eee0c
4
- data.tar.gz: 66a73f2d9ae4fadd454a25985d491fb3cab67aff4720c2c67a6173b902edcbcc
3
+ metadata.gz: 25706f6a131ad3135e14aae02f1c5d5afc3a60a2ed6286246ec0393f3e5aae13
4
+ data.tar.gz: dbf294af717937e6168a52c074e604afbd47d5e372285b9795e5ed3edceba73a
5
5
  SHA512:
6
- metadata.gz: 441e2cef13aad2345f16f3be8e67907731f055f1d3760ba6ca6d46e91f8ccd5e343c93d58fefd56c7a25b7490f1a4483a761a859c56c95775616b827a9686823
7
- data.tar.gz: 255341610fea9f2e88d9f73a693396b9cf00e64b08ef8f3f5016de765d0064aa333b1a1ee8052f22c8503b5ac7d26209dd833543ab1a4d095363eb9c8959ff9c
6
+ metadata.gz: 2bd45079a7d9a351f005fe39cee4ed1af442a28bab7e4375089cdd5db6d90e831a183a6c8b2e0721069f46683ea14c7ffc282ed78721ee50a14c067d581bc601
7
+ data.tar.gz: 4a7bcc44a3dd668bde4140428d8cfa9bee262137d6b5fad48afb7e5d11499f2900e6ca5ae50120b168e39146675d2e1be4fd4cf24af7db0af3bafcf1c0f13e21
@@ -8,8 +8,8 @@ rvm:
8
8
  - 2.7.0
9
9
  before_install:
10
10
  - gem install bundler -v 2.1.4
11
- - bundle update --bundler
12
11
  - bundle --version
12
+ - bundle install
13
13
  env:
14
14
  - build_type=ruby
15
15
  script:
data/Makefile CHANGED
@@ -1,3 +1,6 @@
1
+ build:
2
+ gem build hashes_equal.gemspec
3
+
1
4
  lint:
2
5
  bundle exec rubocop
3
6
 
data/README.md CHANGED
@@ -41,6 +41,43 @@ end
41
41
 
42
42
  Underneath, [Hashdiff](https://github.com/liufengyun/hashdiff) is used to perform the comparison.
43
43
 
44
+ You may also use `assert_enumerable_equal` from `EnumerableCompareHelper`:
45
+ ```ruby
46
+ def test_disagreement_in_arrays
47
+ expected_beatles = [
48
+ { firstname: 'John', lastname: 'Lennon' },
49
+ { firstname: 'Paul', lastname: 'McCartney' },
50
+ { firstname: 'Ringo', lastname: 'Starr' },
51
+ { firstname: 'George', lastname: 'Harrison' }
52
+ ]
53
+ actual_beatles = [
54
+ { firstname: 'John', lastname: 'Lennon' },
55
+ { firstname: 'Paul', lastname: 'McCartney' },
56
+ { firstname: 'Ringo', lastname: nil },
57
+ { firstname: 'George', lastname: 'Harrison' }
58
+ ]
59
+
60
+ assert_enumerable_equal(
61
+ expected_beatles,
62
+ actual_beatles
63
+ )
64
+ end
65
+ ```
66
+ ```bash
67
+ test_disagreement_in_arrays FAIL (0.00s)
68
+
69
+ actual value for [2] is missing, expected was
70
+ {:firstname=>"Ringo", :lastname=>"Starr"}
71
+ spurious value {:firstname=>"Ringo", :lastname=>nil} for [2] was not expected.
72
+ --- expected
73
+ +++ actual
74
+ @@ -1 +1 @@
75
+ -[{:firstname=>"John", :lastname=>"Lennon"}, {:firstname=>"Paul", :lastname=>"McCartney"}, {:firstname=>"Ringo", :lastname=>"Starr"}, {:firstname=>"George", :lastname=>"Harrison"}]
76
+ +[{:firstname=>"John", :lastname=>"Lennon"}, {:firstname=>"Paul", :lastname=>"McCartney"}, {:firstname=>"Ringo", :lastname=>nil}, {:firstname=>"George", :lastname=>"Harrison"}]
77
+ hashes_equal/lib/hashes_equal/enumerable_compare_helper.rb:13:in `assert_enumerable_equal'
78
+ ```
79
+ The quality of the results you will get, will depend on Hashdiff ability to process the Enumerable you are comparing.
80
+
44
81
  ## Installation
45
82
 
46
83
  Add this line to your application's Gemfile:
@@ -96,6 +133,43 @@ end
96
133
  hashes_equal/lib/hashes_equal/hash_compare_helper.rb:13:in `assert_hashes_equal'
97
134
  ```
98
135
 
136
+ You may also use `assert_enumerable_equal` from `EnumerableCompareHelper`:
137
+ ```ruby
138
+ def test_disagreement_in_arrays
139
+ expected_beatles = [
140
+ { firstname: 'John', lastname: 'Lennon' },
141
+ { firstname: 'Paul', lastname: 'McCartney' },
142
+ { firstname: 'Ringo', lastname: 'Starr' },
143
+ { firstname: 'George', lastname: 'Harrison' }
144
+ ]
145
+ actual_beatles = [
146
+ { firstname: 'John', lastname: 'Lennon' },
147
+ { firstname: 'Paul', lastname: 'McCartney' },
148
+ { firstname: 'Ringo', lastname: nil },
149
+ { firstname: 'George', lastname: 'Harrison' }
150
+ ]
151
+
152
+ assert_enumerable_equal(
153
+ expected_beatles,
154
+ actual_beatles
155
+ )
156
+ end
157
+ ```
158
+ ```bash
159
+ test_disagreement_in_arrays FAIL (0.00s)
160
+
161
+ actual value for [2] is missing, expected was
162
+ {:firstname=>"Ringo", :lastname=>"Starr"}
163
+ spurious value {:firstname=>"Ringo", :lastname=>nil} for [2] was not expected.
164
+ --- expected
165
+ +++ actual
166
+ @@ -1 +1 @@
167
+ -[{:firstname=>"John", :lastname=>"Lennon"}, {:firstname=>"Paul", :lastname=>"McCartney"}, {:firstname=>"Ringo", :lastname=>"Starr"}, {:firstname=>"George", :lastname=>"Harrison"}]
168
+ +[{:firstname=>"John", :lastname=>"Lennon"}, {:firstname=>"Paul", :lastname=>"McCartney"}, {:firstname=>"Ringo", :lastname=>nil}, {:firstname=>"George", :lastname=>"Harrison"}]
169
+ ```
170
+
171
+ Note that `assert_hashes_equal` will only work with Hashes while `assert_enumerable_equal` will accept any two Enumerable (but might or might not be able to compare them depending on their actual interface).
172
+
99
173
  ## Development
100
174
 
101
175
  Run `bundle exec rake test` to run the tests.
@@ -33,7 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.require_paths = ['lib']
34
34
 
35
35
  spec.add_dependency 'ansi', '~> 1.5'
36
- spec.add_dependency 'assertable'
36
+ spec.add_dependency 'assertable', '~> 0.1'
37
+
37
38
  spec.add_dependency 'hashdiff', '~> 1.0', '>= 1.0.1'
38
39
 
39
40
  spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ansi'
3
4
  require 'assertable'
4
5
  require 'hashdiff'
5
6
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HashesEqual
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashes_equal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shippingbo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: assertable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashdiff
43
43
  requirement: !ruby/object:Gem::Requirement