Class: RuboCop::Cop::RSpecRails::HttpStatus::BeStatusStyleChecker

Inherits:
StyleCheckerBase
  • Object
show all
Defined in:
lib/rubocop/cop/rspec_rails/http_status.rb

Overview

:nodoc:

Constant Summary

Constants inherited from StyleCheckerBase

StyleCheckerBase::ALLOWED_STATUSES, StyleCheckerBase::MSG

Instance Attribute Summary

Attributes inherited from StyleCheckerBase

#node

Instance Method Summary collapse

Methods inherited from StyleCheckerBase

#allowed_symbol?, #current, #custom_http_status_code?, #initialize, #message

Constructor Details

This class inherits a constructor from RuboCop::Cop::RSpecRails::HttpStatus::StyleCheckerBase

Instance Method Details

#offense_rangeObject



182
183
184
# File 'lib/rubocop/cop/rspec_rails/http_status.rb', line 182

def offense_range
  node.parent
end

#offensive?Boolean

Returns:

  • (Boolean)


177
178
179
180
# File 'lib/rubocop/cop/rspec_rails/http_status.rb', line 177

def offensive?
  (!node.sym_type? && !custom_http_status_code?) ||
    (!node.int_type? && !allowed_symbol?)
end

#preferObject



186
187
188
189
190
191
192
193
194
# File 'lib/rubocop/cop/rspec_rails/http_status.rb', line 186

def prefer
  if node.sym_type?
    "be_#{node.value}"
  elsif node.int_type?
    "be_#{symbol}"
  elsif node.str_type?
    "be_#{normalize_str}"
  end
end