lib/rubocop/cop/rspec/rails/http_status.rb in rubocop-rspec-2.24.1 vs lib/rubocop/cop/rspec/rails/http_status.rb in rubocop-rspec-2.25.0

- old
+ new

@@ -64,10 +64,12 @@ (send nil? :have_http_status ${int sym str}) PATTERN def on_send(node) http_status(node) do |arg| + return if arg.str_type? && arg.heredoc? + checker = checker_class.new(arg) return unless checker.offensive? add_offense(checker.offense_range, message: checker.message) do |corrector| @@ -103,10 +105,14 @@ def message format(MSG, prefer: prefer, current: current) end + def current + offense_range.source + end + def offense_range node end def allowed_symbol? @@ -127,22 +133,18 @@ def prefer symbol.inspect end - def current - node.value.inspect - end - private def symbol ::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(number) end def number - node.source.delete('"').to_i + node.value.to_i end end # :nodoc: class NumericStyleChecker < StyleCheckerBase @@ -152,14 +154,10 @@ def prefer number.to_s end - def current - symbol.inspect - end - private def symbol node.value end @@ -188,29 +186,25 @@ elsif node.str_type? "be_#{normalize_str}" end end - def current - offense_range.source - end - private def symbol ::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(number) end def number - node.source.to_i + node.value.to_i end def normalize_str - normalized = node.source.delete('"') - if normalized.match?(/\A\d+\z/) - ::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(normalized.to_i) + str = node.value.to_s + if str.match?(/\A\d+\z/) + ::Rack::Utils::SYMBOL_TO_STATUS_CODE.key(str.to_i) else - normalized + str end end end end end