Class: RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase
- Inherits:
-
Object
- Object
- RuboCop::Cop::RSpec::Rails::HttpStatus::StyleCheckerBase
- Defined in:
- lib/rubocop/cop/rspec/rails/http_status.rb
Overview
:nodoc:
Direct Known Subclasses
BeStatusStyleChecker, NumericStyleChecker, SymbolicStyleChecker
Constant Summary collapse
- MSG =
'Prefer `%<prefer>s` over `%<current>s` ' \ 'to describe HTTP status code.'
- ALLOWED_STATUSES =
%i[error success missing redirect].freeze
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #allowed_symbol? ⇒ Boolean
- #custom_http_status_code? ⇒ Boolean
-
#initialize(node) ⇒ StyleCheckerBase
constructor
A new instance of StyleCheckerBase.
- #message ⇒ Object
- #offense_range ⇒ Object
Constructor Details
#initialize(node) ⇒ StyleCheckerBase
Returns a new instance of StyleCheckerBase.
94 95 96 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 94 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
92 93 94 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 92 def node @node end |
Instance Method Details
#allowed_symbol? ⇒ Boolean
106 107 108 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 106 def allowed_symbol? node.sym_type? && ALLOWED_STATUSES.include?(node.value) end |
#custom_http_status_code? ⇒ Boolean
110 111 112 113 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 110 def custom_http_status_code? node.int_type? && !::Rack::Utils::SYMBOL_TO_STATUS_CODE.value?(node.source.to_i) end |
#message ⇒ Object
98 99 100 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 98 def format(MSG, prefer: prefer, current: current) end |
#offense_range ⇒ Object
102 103 104 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 102 def offense_range node end |