rspec-resembles_json_matchers 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/resembles_json_matchers.rb +4 -0
- data/lib/rspec/resembles_json_matchers/resembles_boolean_matcher.rb +24 -0
- data/lib/rspec/resembles_json_matchers/resembles_hash_matcher.rb +4 -4
- data/lib/rspec/resembles_json_matchers/resembles_nil_matcher.rb +24 -0
- data/lib/rspec/resembles_json_matchers/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67063b7a2b5685ac47e58408e3eb9ab2556ebb9c
|
4
|
+
data.tar.gz: 2bda36618f32e3b751c36274eb8f69cb790d4e2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d83fb0f51620c2066dd33e9783e42e8730a69648c738099dce74d037ce3208a4b9a9d90de984f9ca3621a8dcd1b79d1cafc5c8acfb9ddf58c1b5ba7a67cae7ef
|
7
|
+
data.tar.gz: 88245931405c031a0c71a54bfa5a12d07930afbc2651ed1020033b8009d1ebf8d80f74b118f1d0548d3041a3b36890362e1021f2a25eb7e46fb9a3b10416343d
|
@@ -16,6 +16,8 @@ module RSpec
|
|
16
16
|
autoload :ResemblesDateMatcher, "rspec/resembles_json_matchers/resembles_date_matcher"
|
17
17
|
autoload :ResemblesNumericMatcher, "rspec/resembles_json_matchers/resembles_numeric_matcher"
|
18
18
|
autoload :ResemblesStringMatcher, "rspec/resembles_json_matchers/resembles_string_matcher"
|
19
|
+
autoload :ResemblesBooleanMatcher, "rspec/resembles_json_matchers/resembles_boolean_matcher"
|
20
|
+
autoload :ResemblesNilMatcher, "rspec/resembles_json_matchers/resembles_nil_matcher"
|
19
21
|
autoload :ResemblesClassMatcher, "rspec/resembles_json_matchers/resembles_class_matcher"
|
20
22
|
|
21
23
|
def iso8601_timestamp
|
@@ -46,6 +48,8 @@ module RSpec
|
|
46
48
|
ResemblesDateMatcher,
|
47
49
|
ResemblesNumericMatcher,
|
48
50
|
ResemblesStringMatcher,
|
51
|
+
ResemblesBooleanMatcher,
|
52
|
+
ResemblesNilMatcher,
|
49
53
|
ResemblesClassMatcher
|
50
54
|
].freeze
|
51
55
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module RSpec::ResemblesJsonMatchers
|
3
|
+
class ResemblesBooleanMatcher
|
4
|
+
def self.can_match?(bool)
|
5
|
+
bool.is_a?(TrueClass) || bool.is_a?(FalseClass)
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(expected)
|
9
|
+
@expected = expected
|
10
|
+
end
|
11
|
+
|
12
|
+
def description
|
13
|
+
"resemble boolean #{@expected.inspect}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches?(actual)
|
17
|
+
actual == @expected
|
18
|
+
end
|
19
|
+
|
20
|
+
def expected_formatted
|
21
|
+
@expected
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -54,7 +54,7 @@ module RSpec::ResemblesJsonMatchers
|
|
54
54
|
def expected_matchers
|
55
55
|
@expected_matchers ||= {}.tap do |hsh|
|
56
56
|
expected.each do |key, value_matcher|
|
57
|
-
hsh[key] = matcherize(value_matcher)
|
57
|
+
hsh[key.to_s] = matcherize(value_matcher)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -89,19 +89,19 @@ module RSpec::ResemblesJsonMatchers
|
|
89
89
|
.indent(2)
|
90
90
|
|
91
91
|
"attribute #{k.to_s.inspect}:\n#{matcher_failure_message}"
|
92
|
-
end.join("\n")
|
92
|
+
end.join("\n") + "\n"
|
93
93
|
end
|
94
94
|
|
95
95
|
def pretty_unmatched_keys
|
96
96
|
unmatched_keys.map do |key|
|
97
97
|
"attribute #{key.to_s.inspect}:\n is present, but no matcher provided to match it"
|
98
|
-
end.join("\n")
|
98
|
+
end.join("\n") + "\n"
|
99
99
|
end
|
100
100
|
|
101
101
|
def pretty_unmatched_matchers
|
102
102
|
unmatched_matchers.map do |key, matcher|
|
103
103
|
"attribute #{key.to_s.inspect}:\n has a matcher defined, but that attribute was not provided"
|
104
|
-
end.join("\n")
|
104
|
+
end.join("\n") + "\n"
|
105
105
|
end
|
106
106
|
|
107
107
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module RSpec::ResemblesJsonMatchers
|
3
|
+
class ResemblesNilMatcher
|
4
|
+
def self.can_match?(nillish)
|
5
|
+
nillish.nil?
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(expected)
|
9
|
+
@expected = expected
|
10
|
+
end
|
11
|
+
|
12
|
+
def description
|
13
|
+
"resemble boolean #{@expected.inspect}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches?(actual)
|
17
|
+
actual.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def expected_formatted
|
21
|
+
@expected
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
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.6.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:
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -194,10 +194,12 @@ files:
|
|
194
194
|
- lib/rspec/resembles_json_matchers/matcherizer.rb
|
195
195
|
- lib/rspec/resembles_json_matchers/resembles_any_of_matcher.rb
|
196
196
|
- lib/rspec/resembles_json_matchers/resembles_array_matcher.rb
|
197
|
+
- lib/rspec/resembles_json_matchers/resembles_boolean_matcher.rb
|
197
198
|
- lib/rspec/resembles_json_matchers/resembles_class_matcher.rb
|
198
199
|
- lib/rspec/resembles_json_matchers/resembles_date_matcher.rb
|
199
200
|
- lib/rspec/resembles_json_matchers/resembles_hash_matcher.rb
|
200
201
|
- lib/rspec/resembles_json_matchers/resembles_matcher.rb
|
202
|
+
- lib/rspec/resembles_json_matchers/resembles_nil_matcher.rb
|
201
203
|
- lib/rspec/resembles_json_matchers/resembles_numeric_matcher.rb
|
202
204
|
- lib/rspec/resembles_json_matchers/resembles_route_matcher.rb
|
203
205
|
- lib/rspec/resembles_json_matchers/resembles_string_matcher.rb
|
@@ -223,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
225
|
version: '0'
|
224
226
|
requirements: []
|
225
227
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.6.
|
228
|
+
rubygems_version: 2.6.11
|
227
229
|
signing_key:
|
228
230
|
specification_version: 4
|
229
231
|
summary: Helpful matchers for comparing JSON documents.
|