rspec-resembles_json_matchers 0.5.2 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4c1ec81c8d6ae7ed032c6c0fe6e570a4512e4cd
4
- data.tar.gz: cae15755e1911db877633730b1ae0b4a0d6a36ba
3
+ metadata.gz: 67063b7a2b5685ac47e58408e3eb9ab2556ebb9c
4
+ data.tar.gz: 2bda36618f32e3b751c36274eb8f69cb790d4e2a
5
5
  SHA512:
6
- metadata.gz: 895433b102df8420119a4daa125372224362f9e1920467f07ef67c4951ca0012432ca202617c29d3fcfe5adf75e320162da35b1c63990e7ed859e37305a4faaa
7
- data.tar.gz: fcf3df9031572d5c4f22d7ed5cb382a17fe99a82e3652defaaaf05ebe2f249113b48351cf991bf36a90f4deca8720719d2629dd658f375bbdebb5e63fc3fa7b4
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
@@ -1,5 +1,5 @@
1
1
  module Rspec
2
2
  module ResemblesJsonMatchers
3
- VERSION = "0.5.2"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  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.5.2
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: 2016-09-14 00:00:00.000000000 Z
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.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.