diff_matcher 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/lib/diff_matcher/rspec.rb +1 -1
- data/lib/diff_matcher/rspec/matchers.rb +3 -0
- data/lib/diff_matcher/rspec/matchers/diff_json_matcher.rb +31 -0
- data/lib/diff_matcher/rspec/matchers/diff_matcher.rb +3 -3
- data/lib/diff_matcher/rspec_3.rb +1 -1
- data/lib/diff_matcher/rspec_3/matchers.rb +2 -0
- data/lib/diff_matcher/rspec_3/matchers/diff_json_matcher.rb +31 -0
- data/lib/diff_matcher/version.rb +1 -1
- data/spec/diff_matcher/rspec/matchers/diff_matcher_spec.rb +1 -0
- metadata +16 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 85c693faa10896940ac3eebf11393668fd78b0e1
|
4
|
+
data.tar.gz: 38be21bd9cd7d420fc53d2a1378156eefcb7c841
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37da42959f13bd42a3c736b959c8f9685bfc0f44f3a14ae330a3586658f71cceefcad2e5ff223bcfd6d1958b0b25b39f6d1efbe631f852dd0e28a1af0abd2ff6
|
7
|
+
data.tar.gz: f2ac31ed19ecdc51f28a0a5ca93a81a4a7d4292a717a770556adc60c43512d763ea00f2c23460216cad04296cb5980f4805958f9459bc956eefe60e970335df3
|
data/CHANGELOG.md
CHANGED
data/lib/diff_matcher/rspec.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Uses the diff_matcher gem to provide advanced matching abilities, along with nice visual representation of the
|
2
|
+
# diff between JSON.parse(actual) and expected. The functionality set is very helpful for comparing hashes.
|
3
|
+
#
|
4
|
+
# Usage examples:
|
5
|
+
# it { should be_matching(my_var) }
|
6
|
+
# it { should be_matching(my_var).with_options(ignore_additional: true) }
|
7
|
+
#
|
8
|
+
# Options: by default, color_enabled is controlled by Rspec, and quiet is set to true.
|
9
|
+
RSpec::Matchers.define :be_json_matching do |expected|
|
10
|
+
match do |actual|
|
11
|
+
options = { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge(@options || {})
|
12
|
+
@difference = DiffMatcher::Difference.new(expected, JSON.parse(actual), options)
|
13
|
+
@difference.matching?
|
14
|
+
end
|
15
|
+
|
16
|
+
chain :with_options do |options|
|
17
|
+
@options = options
|
18
|
+
end
|
19
|
+
|
20
|
+
failure_message_for_should do |actual|
|
21
|
+
"diff is:\n" + @difference.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
failure_message_for_should_not do |actual|
|
25
|
+
"diff is:\n" + @difference.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
description do
|
29
|
+
"match via DiffMatcher #{expected}" + (@options.blank? ? '' : " with options: #{@options}")
|
30
|
+
end
|
31
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# Uses the diff_matcher gem to provide advanced matching abilities, along with nice visual representation of the
|
2
|
-
# diff between actual and expected. The functionality set is very helpful for comparing hashes.
|
2
|
+
# diff between JSON.parse(actual) and expected. The functionality set is very helpful for comparing hashes.
|
3
3
|
#
|
4
4
|
# Usage examples:
|
5
5
|
# it { should be_matching(my_var) }
|
6
6
|
# it { should be_matching(my_var).with_options(ignore_additional: true) }
|
7
7
|
#
|
8
8
|
# Options: by default, color_enabled is controlled by Rspec, and quiet is set to true.
|
9
|
-
RSpec::Matchers.define :
|
9
|
+
RSpec::Matchers.define :be_json_matching do |expected|
|
10
10
|
match do |actual|
|
11
11
|
options = { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge(@options || {})
|
12
|
-
@difference = DiffMatcher::Difference.new(expected, actual, options)
|
12
|
+
@difference = DiffMatcher::Difference.new(expected, JSON.parse(actual), options)
|
13
13
|
@difference.matching?
|
14
14
|
end
|
15
15
|
|
data/lib/diff_matcher/rspec_3.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Uses the diff_matcher gem to provide advanced matching abilities, along with nice visual representation of the
|
2
|
+
# diff between JSON.parse(actual) and expected. The functionality set is very helpful for comparing hashes.
|
3
|
+
#
|
4
|
+
# Usage examples:
|
5
|
+
# it { should be_matching(my_var) }
|
6
|
+
# it { should be_matching(my_var).with_options(ignore_additional: true) }
|
7
|
+
#
|
8
|
+
# Options: by default, color_enabled is controlled by Rspec, and quiet is set to true.
|
9
|
+
RSpec::Matchers.define :be_json_matching do |expected|
|
10
|
+
match do |actual|
|
11
|
+
options = { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge(@options || {})
|
12
|
+
@difference = DiffMatcher::Difference.new(expected, JSON.parse(actual), options)
|
13
|
+
@difference.matching?
|
14
|
+
end
|
15
|
+
|
16
|
+
chain :with_options do |options|
|
17
|
+
@options = options
|
18
|
+
end
|
19
|
+
|
20
|
+
failure_message do |actual|
|
21
|
+
"diff is:\n" + @difference.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
failure_message_when_negated do |actual|
|
25
|
+
"diff is:\n" + @difference.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
description do
|
29
|
+
"match via DiffMatcher #{expected}" + (@options.blank? ? '' : " with options: #{@options}")
|
30
|
+
end
|
31
|
+
end
|
data/lib/diff_matcher/version.rb
CHANGED
@@ -3,6 +3,7 @@ require 'diff_matcher/rspec'
|
|
3
3
|
|
4
4
|
describe :be_matching do
|
5
5
|
it "should call DiffMatcher::Difference" do
|
6
|
+
pending 'how are custom matchers tested now?'
|
6
7
|
DiffMatcher::Difference.should_receive(:new).with(
|
7
8
|
:expected, :actual, { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge({ :foo => 'bar' })
|
8
9
|
).and_return(double(:matching? => true))
|
metadata
CHANGED
@@ -1,31 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diff_matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
5
|
-
prerelease:
|
4
|
+
version: 2.7.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- locochris
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
13
|
+
description: |
|
14
|
+
DiffMatcher matches input data (eg. from a JSON API) against values,
|
16
15
|
ranges, classes, regexes, procs, custom matchers and/or easily composed,
|
17
|
-
|
18
16
|
nested combinations thereof to produce an easy to read diff string.
|
19
|
-
|
20
|
-
'
|
21
17
|
email: chris@locomote.com.au
|
22
18
|
executables: []
|
23
19
|
extensions: []
|
24
20
|
extra_rdoc_files: []
|
25
21
|
files:
|
26
|
-
- .gitignore
|
27
|
-
- .rspec
|
28
|
-
- .travis.yml
|
22
|
+
- ".gitignore"
|
23
|
+
- ".rspec"
|
24
|
+
- ".travis.yml"
|
29
25
|
- CHANGELOG.md
|
30
26
|
- Gemfile
|
31
27
|
- README.md
|
@@ -38,8 +34,12 @@ files:
|
|
38
34
|
- lib/diff_matcher/difference.rb
|
39
35
|
- lib/diff_matcher/escape_to_html.rb
|
40
36
|
- lib/diff_matcher/rspec.rb
|
37
|
+
- lib/diff_matcher/rspec/matchers.rb
|
38
|
+
- lib/diff_matcher/rspec/matchers/diff_json_matcher.rb
|
41
39
|
- lib/diff_matcher/rspec/matchers/diff_matcher.rb
|
42
40
|
- lib/diff_matcher/rspec_3.rb
|
41
|
+
- lib/diff_matcher/rspec_3/matchers.rb
|
42
|
+
- lib/diff_matcher/rspec_3/matchers/diff_json_matcher.rb
|
43
43
|
- lib/diff_matcher/rspec_3/matchers/diff_matcher.rb
|
44
44
|
- lib/diff_matcher/version.rb
|
45
45
|
- spec/diff_matcher/difference_spec.rb
|
@@ -49,33 +49,26 @@ homepage: http://github.com/diff-matcher/diff_matcher
|
|
49
49
|
licenses:
|
50
50
|
- BSD
|
51
51
|
- MIT
|
52
|
+
metadata: {}
|
52
53
|
post_install_message:
|
53
54
|
rdoc_options: []
|
54
55
|
require_paths:
|
55
56
|
- lib
|
56
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
hash: -213964590511459667
|
65
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
63
|
requirements:
|
68
|
-
- -
|
64
|
+
- - ">="
|
69
65
|
- !ruby/object:Gem::Version
|
70
66
|
version: '0'
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
hash: -213964590511459667
|
74
67
|
requirements: []
|
75
68
|
rubyforge_project:
|
76
|
-
rubygems_version:
|
69
|
+
rubygems_version: 2.4.2
|
77
70
|
signing_key:
|
78
|
-
specification_version:
|
71
|
+
specification_version: 4
|
79
72
|
summary: Generates a diff by matching against user-defined matchers written in ruby.
|
80
73
|
test_files:
|
81
74
|
- spec/diff_matcher/difference_spec.rb
|