Class: CheckPleaseRspecMatcher::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/check_please_rspec_matcher/matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected, flags = {}) ⇒ Matcher

Returns a new instance of Matcher.



12
13
14
15
# File 'lib/check_please_rspec_matcher/matcher.rb', line 12

def initialize(expected, flags = {})
  @expected = expected
  @flags = flags || {}
end

Instance Method Details

#failure_messageObject



22
23
24
25
26
27
28
29
30
# File 'lib/check_please_rspec_matcher/matcher.rb', line 22

def failure_message
  diff_text = ::CheckPlease::Printers.render(diffs, flags)
  count = diffs.length == 1 ? "1 diff" : "#{diffs.length} diffs"
  <<~EOF
    Expected two JSON data structures to match, but found the following #{count}:

    #{diff_text}
  EOF
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/check_please_rspec_matcher/matcher.rb', line 17

def matches?(actual)
  @actual = actual
  diffs.empty?
end