Class: RSpec::Rails::Matchers::HaveHttpStatus::SymbolicStatus Private
- Inherits:
-
Matchers::BuiltIn::BaseMatcher
- Object
- Matchers::BuiltIn::BaseMatcher
- RSpec::Rails::Matchers::HaveHttpStatus::SymbolicStatus
- Includes:
- RSpec::Rails::Matchers::HaveHttpStatus
- Defined in:
- lib/rspec/rails/matchers/have_http_status.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides an implementation for have_http_status
matching against
Rack symbol http status codes.
Not intended to be instantiated directly.
Instance Method Summary collapse
- #description ⇒ String private
-
#failure_message ⇒ String
private
Explaining why the match failed.
-
#failure_message_when_negated ⇒ String
private
Explaining why the match failed.
-
#initialize(status) ⇒ SymbolicStatus
constructor
private
A new instance of SymbolicStatus.
-
#matches?(response) ⇒ Boolean
private
true
if Rack's associated numeric HTTP code matched theresponse
code.
Methods included from RSpec::Rails::Matchers::HaveHttpStatus
as_test_response, #invalid_response_type_message, matcher_for_status
Constructor Details
#initialize(status) ⇒ SymbolicStatus
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SymbolicStatus.
126 127 128 129 130 131 132 133 |
# File 'lib/rspec/rails/matchers/have_http_status.rb', line 126 def initialize(status) @expected_status = status @actual = nil @invalid_response = nil unless set_expected_code! raise ArgumentError, "Invalid HTTP status: #{status.inspect}" end end |
Instance Method Details
#description ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
148 149 150 |
# File 'lib/rspec/rails/matchers/have_http_status.rb', line 148 def description "respond with status code #{pp_expected}" end |
#failure_message ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns explaining why the match failed.
153 154 155 156 157 |
# File 'lib/rspec/rails/matchers/have_http_status.rb', line 153 def || "expected the response to have status code #{pp_expected} but it" + " was #{pp_actual}" end |
#failure_message_when_negated ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns explaining why the match failed.
160 161 162 163 164 |
# File 'lib/rspec/rails/matchers/have_http_status.rb', line 160 def || "expected the response not to have status code #{pp_expected} " + "but it did" end |
#matches?(response) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true
if Rack's associated numeric HTTP code matched
the response
code.
138 139 140 141 142 143 144 145 |
# File 'lib/rspec/rails/matchers/have_http_status.rb', line 138 def matches?(response) test_response = as_test_response(response) @actual = test_response.response_code expected == @actual rescue TypeError => _ignored @invalid_response = response false end |