module RSpec::Rails::Matchers
def have_http_status(target)
- See: https://github.com/rack/rack/blob/master/lib/rack/utils.rb - `Rack::Utils::SYMBOL_TO_STATUS_CODE`
See: https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/testing/test_response.rb - `ActionDispatch::TestResponse`
Other tags:
- Example: Works with standard `response` objects and Capybara's `page` -
Example: Accepts numeric and symbol statuses -
Other tags:
- Api: - public
def have_http_status(target) raise ArgumentError, "Invalid HTTP status: nil" unless target HaveHttpStatus.matcher_for_status(target) end