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.
Defined Under Namespace
Classes: NumericStyleChecker, 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_pattern, #numblock_pattern, #send_pattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#http_status(node) ⇒ Object
39 40 41 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 39 def_node_matcher :http_status, <<-PATTERN (send nil? :have_http_status ${int sym}) PATTERN |
#on_send(node) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 43 def on_send(node) http_status(node) do |ast_node| checker = checker_class.new(ast_node) return unless checker.offensive? add_offense(checker.node, message: checker.) do |corrector| corrector.replace(checker.node, checker.preferred_style) end end end |