Class: APIMatchers::ResponseBody::HaveJson
- Inherits:
-
Object
- Object
- APIMatchers::ResponseBody::HaveJson
- Includes:
- Core::Parser
- Defined in:
- lib/api_matchers/response_body/have_json.rb
Instance Attribute Summary collapse
-
#expected_json ⇒ Object
readonly
Returns the value of attribute expected_json.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
Instance Method Summary collapse
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
-
#initialize(expected_json) ⇒ HaveJson
constructor
A new instance of HaveJson.
- #matches?(actual) ⇒ Boolean
Methods included from Core::Parser
Constructor Details
#initialize(expected_json) ⇒ HaveJson
Returns a new instance of HaveJson.
7 8 9 |
# File 'lib/api_matchers/response_body/have_json.rb', line 7 def initialize(expected_json) @expected_json = expected_json end |
Instance Attribute Details
#expected_json ⇒ Object (readonly)
Returns the value of attribute expected_json.
5 6 7 |
# File 'lib/api_matchers/response_body/have_json.rb', line 5 def expected_json @expected_json end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
5 6 7 |
# File 'lib/api_matchers/response_body/have_json.rb', line 5 def response_body @response_body end |
Instance Method Details
#failure_message ⇒ Object Also known as: failure_message_for_should
17 18 19 |
# File 'lib/api_matchers/response_body/have_json.rb', line 17 def "expect to have json: '#{expected_json}'. Got: '#{json}'." end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
21 22 23 |
# File 'lib/api_matchers/response_body/have_json.rb', line 21 def "expect to NOT have json: '#{response_body}'." end |
#matches?(actual) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/api_matchers/response_body/have_json.rb', line 11 def matches?(actual) @response_body = actual @expected_json == json end |