Class: RuboCop::Cop::Lint::NoVCRRecording

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

Overview

Examples:

# bad
vcr: { record_mode: :once, tag: :foo }
vcr: { record_mode: :none }

# good
vcr: { tag: :foo }
vcr: true

Constant Summary collapse

MSG =
"Do not set :record option in VCR"

Instance Method Summary collapse

Instance Method Details

#on_pair(node) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rubocop/cop/lint/no_vcr_recording.rb', line 47

def on_pair(node)
  return unless is_only_setting_record_option?(node) || is_setting_record_option?(node)

  add_offense(node) do |corrector|
    if is_only_setting_record_option?(node)
      corrector.replace(node, "vcr: true")
    elsif is_setting_record_option?(node)
      corrector.replace(node, remove_record_option(node))
    end
  end
end