Class: RuboCop::Cop::Sevencop::RSpecRailsStatusCodeCheckBySubject
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sevencop::RSpecRailsStatusCodeCheckBySubject
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/sevencop/rspec_rails_status_code_check_by_subject.rb
Overview
Use ‘expect(response).to have_http_status(code)` instead of `is_expected.to eq(code)`.
Constant Summary collapse
- MSG =
'Use `expect(response).to have_http_status(code)` instead of `is_expected.to eq(code)`.'
- RESTRICT_ON_SEND =
%i[ to ].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ void
This method returns an undefined value.
31 32 33 34 35 36 37 38 39 |
# File 'lib/rubocop/cop/sevencop/rspec_rails_status_code_check_by_subject.rb', line 31 def on_send(node) return unless is_expected_to_eq_code?(node) add_offense(node) do |corrector| corrector.insert_before(node, "subject\n") corrector.replace(node.receiver, 'expect(response)') corrector.replace(node.first_argument.location.selector, 'have_http_status') end end |