Class: DebugExceptionsJson::Rspec::Matchers::StatusCodeMatcher
- Inherits:
-
Object
- Object
- DebugExceptionsJson::Rspec::Matchers::StatusCodeMatcher
- Defined in:
- lib/debug_exceptions_json/rspec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
-
#initialize(expected_code) ⇒ StatusCodeMatcher
constructor
A new instance of StatusCodeMatcher.
-
#matches?(response) ⇒ Boolean
response - A Rack::Response.
Constructor Details
#initialize(expected_code) ⇒ StatusCodeMatcher
Returns a new instance of StatusCodeMatcher.
12 13 14 |
# File 'lib/debug_exceptions_json/rspec/matchers.rb', line 12 def initialize(expected_code) @expected = expected_code end |
Instance Method Details
#description ⇒ Object
38 39 40 |
# File 'lib/debug_exceptions_json/rspec/matchers.rb', line 38 def description "respond with numeric status code #{@expected}" end |
#failure_message ⇒ Object Also known as: failure_message_for_should
16 17 18 19 20 21 22 23 24 |
# File 'lib/debug_exceptions_json/rspec/matchers.rb', line 16 def = "expected the response to have status code #{@expected} but it was #{@actual}." if dump_exception?(@response) [, dumped_exception].join("\n\n") else end end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
27 28 29 30 31 32 33 34 35 |
# File 'lib/debug_exceptions_json/rspec/matchers.rb', line 27 def = "expected the response not to have status code #{@expected} but it did" if dump_exception?(@response) [, dumped_exception].join("\n\n") else end end |
#matches?(response) ⇒ Boolean
response - A Rack::Response
43 44 45 46 47 |
# File 'lib/debug_exceptions_json/rspec/matchers.rb', line 43 def matches?(response) @response = response @actual = response.status @actual == @expected end |