Class: JsonResponseMatchers::Content
- Defined in:
- lib/json_response_matchers/content.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ Content
constructor
A new instance of Content.
- #matches?(actual) ⇒ Boolean
- #with_full_match ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(expected) ⇒ Content
Returns a new instance of Content.
5 6 7 8 9 10 11 12 |
# File 'lib/json_response_matchers/content.rb', line 5 def initialize expected super @exact = true if Hash === @expected @expected.deep_stringify_keys! @exact = false end end |
Instance Method Details
#failure_message ⇒ Object
14 15 16 |
# File 'lib/json_response_matchers/content.rb', line 14 def "expected\n #{@actual}\nto #{@exact ? 'equal' : 'include'}\n #{@expected}" end |
#matches?(actual) ⇒ Boolean
19 20 21 22 |
# File 'lib/json_response_matchers/content.rb', line 19 def matches? actual @actual = fetch_from extract_parsed_json_from actual @exact ? @actual == @expected : hash_include? end |
#with_full_match ⇒ Object
24 25 26 27 |
# File 'lib/json_response_matchers/content.rb', line 24 def with_full_match @exact = true self end |