Class: CheckPleaseRspecMatcher::Matcher
- Inherits:
-
Object
- Object
- CheckPleaseRspecMatcher::Matcher
- Defined in:
- lib/check_please_rspec_matcher/matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected, flags = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(actual) ⇒ Boolean
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_message ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/check_please_rspec_matcher/matcher.rb', line 22 def 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
17 18 19 20 |
# File 'lib/check_please_rspec_matcher/matcher.rb', line 17 def matches?(actual) @actual = actual diffs.empty? end |