Class: JsonMatcher::Matcher
- Inherits:
-
Object
- Object
- JsonMatcher::Matcher
- Includes:
- Term::ANSIColor
- Defined in:
- lib/json_matcher.rb
Instance Method Summary collapse
-
#initialize(actual, expected, opts = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #similar? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(actual, expected, opts = {}) ⇒ Matcher
Returns a new instance of Matcher.
14 15 16 17 18 19 20 21 |
# File 'lib/json_matcher.rb', line 14 def initialize actual, expected, opts = {} @actual = actual @expected = expected @actual_hash = JSON.parse actual @expected_hash = JSON.parse expected @options = opts @failure_msg = { :extra => {}, :less => {}} end |
Instance Method Details
#similar? ⇒ Boolean
23 24 25 |
# File 'lib/json_matcher.rb', line 23 def similar? @options[:exact] ? equal : equal_without_order end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/json_matcher.rb', line 27 def to_s red { bold {"Diff:\n+#{@failure_msg[:extra].to_json}\n-#{@failure_msg[:less].to_json}" } } end |