rspec-resembles_json_matchers 0.8.0 → 0.9.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
  SHA256:
3
- metadata.gz: 8c9a61de4b2be0f18eada606356321688910baf9dc9a8c662648bea89e068422
4
- data.tar.gz: '068d9310ca39fb2bdf735b3bdf0bf1ce94b64c649f43ab19f86361b1ec3213d2'
3
+ metadata.gz: 171dd3d381b09534f9c969e2ce6633e8132bb34fdc23e78121ba363db7bbef11
4
+ data.tar.gz: 9823e5b275f1f8afce373ba250987feba065f22ad53bc1daced15392aaf7ddda
5
5
  SHA512:
6
- metadata.gz: 100c49f936bc8177ee0ab361d920cf2ade74b4c5cf07d17adbff6372aabe9b6ba7cee3f8c6120233bfb276913fac56c9901cc700762bfac356273d63d47d0c4f
7
- data.tar.gz: 844f1bf3f602a8a33f0fde5154c99cfa2f8ad92704070356ab5d56fb59eb9563a4d79fc3f633a96e3ee3950d577179ffbddd1568e0b310fe283f2ade5b4bb666
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.actual.nil? || matcher.actual.empty?
103
- example_matcher = matcher.expected.first
104
- render example_matcher, prefix: prefix + " ", starts_on_newline: true
105
- @buffer.puts
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}"
@@ -16,7 +16,7 @@ module RSpec::ResemblesJsonMatchers
16
16
  end
17
17
 
18
18
  def matches?(actual)
19
- actual == @expected
19
+ actual.is_a?(TrueClass) || actual.is_a?(FalseClass)
20
20
  end
21
21
 
22
22
  def expected_formatted
@@ -1,5 +1,5 @@
1
1
  module Rspec
2
2
  module ResemblesJsonMatchers
3
- VERSION = "0.8.0"
3
+ VERSION = "0.9.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.8.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-06-05 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler