Class: RuboCop::Cop::RSpec::Rails::HaveHttpStatus

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/rails/have_http_status.rb

Overview

Checks that tests use ‘have_http_status` instead of equality matchers.

Examples:

ResponseMethods: [‘response’, ‘last_response’] (default)

# bad
expect(response.status).to be(200)
expect(last_response.code).to eq("200")

# good
expect(response).to have_http_status(200)
expect(last_response).to have_http_status(200)

ResponseMethods: [‘foo_response’]

# bad
expect(foo_response.status).to be(200)

# good
expect(foo_response).to have_http_status(200)

# also good
expect(response).to have_http_status(200)
expect(last_response).to have_http_status(200)