rspec-resembles_json_matchers 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/lib/rspec/resembles_json_matchers/attribute_differ.rb +15 -5
- data/lib/rspec/resembles_json_matchers/resembles_any_of_matcher.rb +7 -2
- data/lib/rspec/resembles_json_matchers/resembles_boolean_matcher.rb +1 -1
- data/lib/rspec/resembles_json_matchers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 171dd3d381b09534f9c969e2ce6633e8132bb34fdc23e78121ba363db7bbef11
|
4
|
+
data.tar.gz: 9823e5b275f1f8afce373ba250987feba065f22ad53bc1daced15392aaf7ddda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f678970b2c26c9d686eb91408a94e175d98ce5c129504826e89e7820628e874999053da7f8d60a4794082502b7188cd36231a649648f27e0db66c0ad15db8c6
|
7
|
+
data.tar.gz: e39a63623c04f2aec16dcacccf56a64b2db8bff0c110cc1749ce134d4f770623c68862fcbf30c4ab2383e954cda0ca9195b57aa6d423bbd01458b4d4574249ac
|
data/Changelog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.9.0
|
2
|
+
|
3
|
+
- ResemblesBoolean doesn't care about the value of the boolean, only that it
|
4
|
+
is a boolean.
|
5
|
+
- ResemblesAnyOf with non-homogeneous arrays no longer prints errors when the
|
6
|
+
overall array matched successfully.
|
7
|
+
|
1
8
|
# 0.8.0
|
2
9
|
|
3
10
|
- ResemblesJson now fails if there are unexpected keys in the actual hash
|
@@ -99,14 +99,24 @@ module RSpec::ResemblesJsonMatchers
|
|
99
99
|
|
100
100
|
def render_ResemblesAnyOfMatcher(matcher, prefix: "", **opts)
|
101
101
|
@buffer.puts "["
|
102
|
-
if matcher.
|
103
|
-
|
104
|
-
|
105
|
-
|
102
|
+
if matcher.matched?
|
103
|
+
matcher.original_expected.each do |item|
|
104
|
+
@buffer.print JSON.pretty_generate(item).indent(1, NORMAL_COLOR + prefix + "- ")
|
105
|
+
last = (matcher.original_expected.last == item)
|
106
|
+
@buffer.print(",") unless last
|
107
|
+
@buffer.puts
|
108
|
+
end
|
109
|
+
elsif matcher.actual.nil? || matcher.actual.empty?
|
110
|
+
matcher.expected.each do |expected_matcher|
|
111
|
+
render expected_matcher, prefix: prefix + " ", starts_on_newline: true
|
112
|
+
last = (matcher.expected.last == expected_matcher)
|
113
|
+
@buffer.print(",") unless last
|
114
|
+
@buffer.puts
|
115
|
+
end
|
106
116
|
else
|
107
117
|
matcher.attempted_matchers.each do |attempted_matcher|
|
108
|
-
last = (matcher.attempted_matchers.last == attempted_matcher)
|
109
118
|
render attempted_matcher, prefix: prefix + " ", starts_on_newline: true
|
119
|
+
last = (matcher.attempted_matchers.last == attempted_matcher)
|
110
120
|
@buffer.print(",") unless last
|
111
121
|
@buffer.puts
|
112
122
|
end
|
@@ -8,19 +8,24 @@ module RSpec::ResemblesJsonMatchers
|
|
8
8
|
array.is_a? Array
|
9
9
|
end
|
10
10
|
|
11
|
-
attr_reader :expected, :actual
|
11
|
+
attr_reader :expected, :actual, :original_expected
|
12
12
|
|
13
13
|
def initialize(expected)
|
14
|
+
@original_expected = expected
|
14
15
|
@expected = expected.map { |e| matcherize(e) }
|
15
16
|
end
|
16
17
|
|
17
18
|
def matches?(actual)
|
18
19
|
@actual = Array.wrap(actual)
|
19
|
-
@actual.all? do |a|
|
20
|
+
@matched = @actual.all? do |a|
|
20
21
|
expected_matchers.any? { |m| attempted_matchers << m; m.matches? a }
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
def matched?
|
26
|
+
@matched
|
27
|
+
end
|
28
|
+
|
24
29
|
def description
|
25
30
|
if @expected.size == 1
|
26
31
|
"have every item #{expected_matchers.first.description}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-resembles_json_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Sadauskas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|