Class: RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker
- Inherits:
-
Object
- Object
- RuboCop::Cop::RSpec::Rails::HttpStatus::NumericStyleChecker
- Defined in:
- lib/rubocop/cop/rspec/rails/http_status.rb
Overview
:nodoc:
Constant Summary collapse
- MSG =
'Prefer `%<prefer>s` over `%<current>s` ' \ 'to describe HTTP status code.'
- WHITELIST_STATUS =
%i[error success missing redirect].freeze
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node) ⇒ NumericStyleChecker
constructor
A new instance of NumericStyleChecker.
- #message ⇒ Object
- #offensive? ⇒ Boolean
- #preferred_style ⇒ Object
Constructor Details
#initialize(node) ⇒ NumericStyleChecker
Returns a new instance of NumericStyleChecker.
113 114 115 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 113 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
112 113 114 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 112 def node @node end |
Instance Method Details
#message ⇒ Object
121 122 123 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 121 def format(MSG, prefer: preferred_style, current: symbol.inspect) end |
#offensive? ⇒ Boolean
117 118 119 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 117 def offensive? !node.int_type? && !whitelisted_symbol? end |
#preferred_style ⇒ Object
125 126 127 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 125 def preferred_style number.to_s end |