diff_matcher 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -1
- data/.travis.yml +2 -1
- data/CHANGELOG.md +9 -5
- data/Gemfile +4 -4
- data/README.md +37 -29
- data/diff_matcher.gemspec +3 -3
- data/lib/diff_matcher/difference.rb +1 -1
- data/lib/diff_matcher/version.rb +1 -1
- data/spec/diff_matcher/difference_spec.rb +20 -8
- data/spec/spec_helper.rb +2 -1
- metadata +26 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 263716b9ab7bbdc763e3ee639f6a8ecdcca95661
|
4
|
+
data.tar.gz: 193438c3843d95b7dd6d1d311ea7f5da4c98d6e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abbfb0e8738b88efc5a8d5546cb02e7ffc845c76255d7cf1542391c8140abdec7b21d072cb9a913d7d75f876b47a21f7e6b2a71e80c99e0f9490ada00f922571
|
7
|
+
data.tar.gz: f1d2222a64acc05739651604c378a4a9f33998d91af454f3d0c3805fa02bc0b1d7ec81032ec284da8c0c7afef5d845e46eeac81ad40eb60a30a22a842c3a1192
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v2.4.1
|
4
|
+
|
5
|
+
* BUGFIX match values where their classes are different but one is a subclass of the other
|
6
|
+
|
3
7
|
### v2.4.0
|
4
8
|
|
5
|
-
|
9
|
+
* Add class configuration of Difference from a block
|
6
10
|
|
7
11
|
### v2.3.3
|
8
12
|
|
9
|
-
|
13
|
+
* Allow HTML output using `:html_output=>true` option
|
10
14
|
|
11
15
|
### v2.3.2
|
12
16
|
|
@@ -19,13 +23,13 @@
|
|
19
23
|
### v2.2.3
|
20
24
|
|
21
25
|
* set color_enabled/color_scheme on the class
|
22
|
-
|
26
|
+
|
23
27
|
(ie. so it can be used by default)
|
24
28
|
|
25
29
|
### v2.2.2
|
26
30
|
|
27
31
|
* BUGFIX for `AllMatcher`
|
28
|
-
|
32
|
+
|
29
33
|
- return a diff instead of raising an exception
|
30
34
|
- (raising an exception was a bad idea as it blew up the entire match
|
31
35
|
when used in conjuction with an or-matcher, or embedded into other
|
@@ -45,7 +49,7 @@
|
|
45
49
|
### v2.0.0
|
46
50
|
|
47
51
|
* Remove `:verbose` option
|
48
|
-
|
52
|
+
|
49
53
|
More often than not users want this as the default.
|
50
54
|
|
51
55
|
### v1.0.1
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem "rake" , "~>
|
7
|
-
gem "rspec", "~> 2.
|
6
|
+
gem "rake" , "~> 10.1"
|
7
|
+
gem "rspec", "~> 2.14"
|
8
8
|
|
9
9
|
platforms :mri_19 do
|
10
10
|
gem "simplecov"
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
DiffMatcher
|
2
2
|
===
|
3
3
|
|
4
|
-
[](https://travis-ci.org/diff-matcher/diff_matcher)
|
5
|
+
[](http://badge.fury.io/rb/diff_matcher)
|
6
|
+
[](https://gemnasium.com/diff-matcher/diff_matcher)
|
7
|
+
[](http://stillmaintained.com/diff-matcher/diff_matcher)
|
6
8
|
|
7
9
|
Generates a diff by matching against user-defined matchers written in ruby.
|
8
10
|
|
@@ -301,7 +303,7 @@ Using the `:default` colour scheme items shown in a difference are coloured as f
|
|
301
303
|
|
302
304
|
Other colour schemes, eg. `:color_scheme=>:white_background` will use different colour mappings.
|
303
305
|
|
304
|
-
|
306
|
+
|
305
307
|
|
306
308
|
Similar gems
|
307
309
|
---
|
@@ -353,34 +355,40 @@ do pattern matching and also looks like a good alternative to diff_matcher, it h
|
|
353
355
|
|
354
356
|
Use with rspec
|
355
357
|
---
|
356
|
-
To use with rspec create
|
358
|
+
To use with rspec, create a custom matcher. The following example matcher works with rspec-1.2.4 and up.
|
357
359
|
|
358
360
|
``` ruby
|
359
361
|
require 'diff_matcher'
|
360
362
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
363
|
+
# Uses the diff_matcher gem to provide advanced matching abilities, along with nice visual representation of the
|
364
|
+
# diff between actual and expected. The functionality set is very helpful for comparing hashes.
|
365
|
+
#
|
366
|
+
# Usage examples:
|
367
|
+
# it { should be_matching(my_var) }
|
368
|
+
# it { should be_matching(my_var).with_options(ignore_additional: true) }
|
369
|
+
#
|
370
|
+
# Options: by default, color_enabled is controlled by Rspec, and quiet is set to true.
|
371
|
+
RSpec::Matchers.define :be_matching do |expected|
|
372
|
+
match do |actual|
|
373
|
+
options = { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge(@options || {})
|
374
|
+
@difference = DiffMatcher::Difference.new(expected, actual, options)
|
375
|
+
@difference.matching?
|
376
|
+
end
|
377
|
+
|
378
|
+
chain :with_options do |options|
|
379
|
+
@options = options
|
380
|
+
end
|
381
|
+
|
382
|
+
failure_message_for_should do |actual|
|
383
|
+
"diff is:\n" + @difference.to_s
|
384
|
+
end
|
385
|
+
|
386
|
+
failure_message_for_should_not do |actual|
|
387
|
+
"diff is:\n" + @difference.to_s
|
388
|
+
end
|
389
|
+
|
390
|
+
description do
|
391
|
+
"match via DiffMatcher #{expected}" + (@options.blank? ? '' : " with options: #{@options}")
|
384
392
|
end
|
385
393
|
end
|
386
394
|
```
|
@@ -392,7 +400,7 @@ describe "hash matcher" do
|
|
392
400
|
subject { { :a=>1, :b=>2, :c=>'3', :d=>4, :e=>"additional stuff" } }
|
393
401
|
let(:expected) { { :a=>1, :b=>Fixnum, :c=>/[0-9]/, :d=>lambda { |x| (3..5).include?(x) } } }
|
394
402
|
|
395
|
-
it { should be_matching(expected
|
403
|
+
it { should be_matching(expected).with_options(:ignore_additional=>true) }
|
396
404
|
it { should be_matching(expected) }
|
397
405
|
end
|
398
406
|
```
|
@@ -431,5 +439,5 @@ Status
|
|
431
439
|
|
432
440
|
Our company is using this gem to test our JSON API which has got above and beyond a stable v1.0.0 release.
|
433
441
|
|
434
|
-
There's a [pull request](http://github.com/rspec/rspec-expectations/pull/79) to use this gem in a `be_hash_matching`
|
442
|
+
There's a [pull request](http://github.com/rspec/rspec-expectations/pull/79) to use this gem in a `be_hash_matching`
|
435
443
|
[rspec matcher](https://www.relishapp.com/rspec/rspec-expectations).
|
data/diff_matcher.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = "diff_matcher"
|
8
8
|
s.version = DiffMatcher::VERSION.dup
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.authors = ["
|
11
|
-
s.email = "chris@
|
12
|
-
s.homepage = "http://github.com/
|
10
|
+
s.authors = ["locochris"]
|
11
|
+
s.email = "chris@locomote.com.au"
|
12
|
+
s.homepage = "http://github.com/diff-matcher/diff_matcher"
|
13
13
|
|
14
14
|
s.summary = %q{Generates a diff by matching against user-defined matchers written in ruby.}
|
15
15
|
s.description = <<EOF
|
data/lib/diff_matcher/version.rb
CHANGED
@@ -133,7 +133,7 @@ describe "DiffMatcher::Matcher[expected].diff(actual, opts)" do
|
|
133
133
|
2
|
134
134
|
|
135
135
|
it_behaves_like "a diff matcher", expected, same, different,
|
136
|
-
"\e[31m- \e[1m1\e[0m\e[33m+ \e[1m2\e[0m"
|
136
|
+
"\e[31m- \e[1m1\e[0m\e[33m+ \e[1m2\e[0m"
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -163,7 +163,7 @@ describe "DiffMatcher::difference(expected, actual, opts)" do
|
|
163
163
|
2
|
164
164
|
|
165
165
|
it_behaves_like "a diff matcher", expected, same, different,
|
166
|
-
<<-EOF
|
166
|
+
<<-EOF
|
167
167
|
- 1+ 2
|
168
168
|
Where, - 1 missing, + 1 additional
|
169
169
|
EOF
|
@@ -176,7 +176,7 @@ describe "DiffMatcher::difference(expected, actual, opts)" do
|
|
176
176
|
"b"
|
177
177
|
|
178
178
|
it_behaves_like "a diff matcher", expected, same, different,
|
179
|
-
<<-EOF
|
179
|
+
<<-EOF
|
180
180
|
- "a"+ "b"
|
181
181
|
Where, - 1 missing, + 1 additional
|
182
182
|
EOF
|
@@ -185,17 +185,29 @@ describe "DiffMatcher::difference(expected, actual, opts)" do
|
|
185
185
|
different = 0
|
186
186
|
|
187
187
|
it_behaves_like "a diff matcher", expected, same, different,
|
188
|
-
<<-EOF
|
188
|
+
<<-EOF
|
189
189
|
- "a"+ 0
|
190
190
|
Where, - 1 missing, + 1 additional
|
191
191
|
EOF
|
192
|
+
|
193
|
+
context "expected class is a subclass of actual class" do
|
194
|
+
class SubString < String; end
|
195
|
+
same = SubString.new("a")
|
196
|
+
different = SubString.new("b")
|
197
|
+
|
198
|
+
it_behaves_like "a diff matcher", expected, same, different,
|
199
|
+
<<-EOF
|
200
|
+
- "a"+ "b"
|
201
|
+
Where, - 1 missing, + 1 additional
|
202
|
+
EOF
|
203
|
+
end
|
192
204
|
end
|
193
205
|
|
194
206
|
context "when actual is nil" do
|
195
207
|
different = nil
|
196
208
|
|
197
209
|
it_behaves_like "a diff matcher", expected, same, different,
|
198
|
-
<<-EOF
|
210
|
+
<<-EOF
|
199
211
|
- "a"+ nil
|
200
212
|
Where, - 1 missing, + 1 additional
|
201
213
|
EOF
|
@@ -209,7 +221,7 @@ describe "DiffMatcher::difference(expected, actual, opts)" do
|
|
209
221
|
false
|
210
222
|
|
211
223
|
it_behaves_like "a diff matcher", expected, same, different,
|
212
|
-
<<-EOF
|
224
|
+
<<-EOF
|
213
225
|
- nil+ false
|
214
226
|
Where, - 1 missing, + 1 additional
|
215
227
|
EOF
|
@@ -222,7 +234,7 @@ describe "DiffMatcher::difference(expected, actual, opts)" do
|
|
222
234
|
[ 2 ]
|
223
235
|
|
224
236
|
it_behaves_like "a diff matcher", expected, same, different,
|
225
|
-
<<-EOF
|
237
|
+
<<-EOF
|
226
238
|
[
|
227
239
|
- 1+ 2
|
228
240
|
]
|
@@ -335,7 +347,7 @@ describe "DiffMatcher::difference(expected, actual, opts)" do
|
|
335
347
|
ArrayChild[ 2 ]
|
336
348
|
|
337
349
|
it_behaves_like "a diff matcher", expected, same, different,
|
338
|
-
<<-EOF
|
350
|
+
<<-EOF
|
339
351
|
[
|
340
352
|
- 1+ 2
|
341
353
|
]
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,31 +1,24 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: diff_matcher
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 2.4.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.1
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
6
|
+
authors:
|
7
|
+
- locochris
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2012-08-05 00:00:00 Z
|
11
|
+
date: 2013-07-28 00:00:00.000000000 Z
|
14
12
|
dependencies: []
|
15
|
-
|
16
13
|
description: |
|
17
14
|
DiffMatcher matches input data (eg. from a JSON API) against values,
|
18
15
|
ranges, classes, regexes, procs, custom matchers and/or easily composed,
|
19
16
|
nested combinations thereof to produce an easy to read diff string.
|
20
|
-
|
21
|
-
email: chris@playup.com
|
17
|
+
email: chris@locomote.com.au
|
22
18
|
executables: []
|
23
|
-
|
24
19
|
extensions: []
|
25
|
-
|
26
20
|
extra_rdoc_files: []
|
27
|
-
|
28
|
-
files:
|
21
|
+
files:
|
29
22
|
- .gitignore
|
30
23
|
- .rspec
|
31
24
|
- .travis.yml
|
@@ -44,35 +37,29 @@ files:
|
|
44
37
|
- lib/diff_matcher/version.rb
|
45
38
|
- spec/diff_matcher/difference_spec.rb
|
46
39
|
- spec/spec_helper.rb
|
47
|
-
homepage: http://github.com/
|
40
|
+
homepage: http://github.com/diff-matcher/diff_matcher
|
48
41
|
licenses: []
|
49
|
-
|
42
|
+
metadata: {}
|
50
43
|
post_install_message:
|
51
44
|
rdoc_options: []
|
52
|
-
|
53
|
-
require_paths:
|
45
|
+
require_paths:
|
54
46
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: "0"
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
70
57
|
requirements: []
|
71
|
-
|
72
58
|
rubyforge_project:
|
73
|
-
rubygems_version:
|
59
|
+
rubygems_version: 2.0.3
|
74
60
|
signing_key:
|
75
|
-
specification_version:
|
61
|
+
specification_version: 4
|
76
62
|
summary: Generates a diff by matching against user-defined matchers written in ruby.
|
77
|
-
test_files:
|
78
|
-
|
63
|
+
test_files:
|
64
|
+
- spec/diff_matcher/difference_spec.rb
|
65
|
+
- spec/spec_helper.rb
|