Class: RuboCop::Cop::RSpec::JsonResponse

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/rspec/json_response.rb

Overview

Prevent using ‘json_response` in spec. Consider using `response.parsed_body`.

Examples:

# bad
expect(json_response)

# good
expect(response.parsed_body)

Constant Summary collapse

MSG =
'Use `response.parsed_body` instead.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rubocop/cop/rspec/json_response.rb', line 25

def on_send(node)
  return unless json_response?(node)

  add_offense(node) do |corrector|
    corrector.replace(node, 'response.parsed_body')
  end
end