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.'
- 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
-
#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.
111 112 113 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 111 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
109 110 111 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 109 def node @node end |
Instance Method Details
#message ⇒ Object
119 120 121 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 119 def format(MSG, prefer: preferred_style, current: symbol.inspect) end |
#offensive? ⇒ Boolean
115 116 117 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 115 def offensive? !node.int_type? && !allowed_symbol? end |
#preferred_style ⇒ Object
123 124 125 |
# File 'lib/rubocop/cop/rspec/rails/http_status.rb', line 123 def preferred_style number.to_s end |