class RSpec::Rails::Matchers::HaveHttpStatus::NumericCode

@see RSpec::Rails::Matchers#have_http_status
expect(response).to have_http_status(404)
@example
Not intended to be instantiated directly.
numeric http status codes.
Provides an implementation for ‘have_http_status` matching against
@api private

def description

Returns:
  • (String) -
def description
  "respond with numeric status code #{expected}"
end

def failure_message

Returns:
  • (String) - explaining why the match failed
def failure_message
  invalid_response_type_message ||
  "expected the response to have status code #{expected.inspect}" \
    " but it was #{actual.inspect}"
end

def failure_message_when_negated

Returns:
  • (String) - explaining why the match failed
def failure_message_when_negated
  invalid_response_type_message ||
  "expected the response not to have status code " \
  "#{expected.inspect} but it did"
end

def initialize(code)

def initialize(code)
  @expected = code.to_i
  @actual = nil
  @invalid_response = nil
end

def matches?(response)

Returns:
  • (Boolean) - `true` if the numeric code matched the `response` code

Parameters:
  • response (Object) -- object providing an http code to match
def matches?(response)
  test_response = as_test_response(response)
  @actual = test_response.response_code.to_i
  expected == @actual
rescue TypeError => _ignored
  @invalid_response = response
  false
end