class RuboCop::Cop::RSpec::Rails::HaveHttpStatus


expect(response).to have_http_status(200)
# good
expect(response.code).to eq(“200”)
expect(response.status).to be(200)
# bad
@example
Checks that tests use ‘have_http_status` instead of equality matchers.

def on_send(node)

def on_send(node)
  match_status(node) do |response_status, to, match, status|
    return unless status.to_s.match?(/\A\d+\z/)
    message = format(MSG, to: to, status: status,
                          bad_code: node.source)
    add_offense(node, message: message) do |corrector|
      corrector.replace(response_status, 'response')
      corrector.replace(match.loc.selector, 'have_http_status')
      corrector.replace(match.first_argument, status.to_s)
    end
  end
end