Method: RuboCop::Cop::RSpec::VariableDefinition#on_send

Defined in:
lib/rubocop/cop/rspec/variable_definition.rb

#on_send(node) ⇒ Object

[View source]

34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rubocop/cop/rspec/variable_definition.rb', line 34

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

  variable_definition?(node) do |variable|
    next unless style_offense?(variable)

    add_offense(
      variable,
      message: format(MSG, style: style)
    ) do |corrector|
      corrector.replace(variable, correct_variable(variable))
    end
  end
end