Class: RuboCop::Cop::RSpec::Rails::HttpStatus
- Extended by:
- AutoCorrector
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rspec/rails/http_status.rb
Overview
Enforces use of symbolic or numeric value to describe HTTP status.
This cop inspects only ‘have_http_status` calls. So, this cop does not check if a method starting with `be_*` is used when setting for `EnforcedStyle: symbolic` or `EnforcedStyle: numeric`.
Defined Under Namespace
Classes: BeStatusStyleChecker, NumericStyleChecker, StyleCheckerBase, SymbolicStyleChecker
Constant Summary collapse
- RESTRICT_ON_SEND =
%i[have_http_status].freeze
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
#block_or_numblock_pattern, #block_pattern, #numblock_pattern, #send_pattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#http_status(node) ⇒ Object
57 58 59 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 57 def_node_matcher :http_status, <<-PATTERN (send nil? :have_http_status ${int sym}) PATTERN |
#on_send(node) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 61 def on_send(node) http_status(node) do |arg| checker = checker_class.new(arg) return unless checker.offensive? add_offense(checker.offense_range, message: checker.) do |corrector| corrector.replace(checker.offense_range, checker.prefer) end end end |