class RuboCop::Cop::RSpec::SharedExamples


include_examples :foo_bar_baz
shared_examples_for :foo_bar_baz
shared_examples :foo_bar_baz
it_should_behave_like :foo_bar_baz
it_behaves_like :foo_bar_baz
# good
include_examples ‘foo bar baz’
shared_examples_for ‘foo bar baz’
shared_examples ‘foo bar baz’
it_should_behave_like ‘foo bar baz’
it_behaves_like ‘foo bar baz’
# bad
@example ‘EnforcedStyle: symbol`
include_examples ’foo bar baz’
shared_examples_for ‘foo bar baz’
shared_examples ‘foo bar baz’
it_should_behave_like ‘foo bar baz’
it_behaves_like ‘foo bar baz’
# good
include_examples :foo_bar_baz
shared_examples_for :foo_bar_baz
shared_examples :foo_bar_baz
it_should_behave_like :foo_bar_baz
it_behaves_like :foo_bar_baz
# bad
@example ‘EnforcedStyle: string` (default)
This cop can be configured using the `EnforcedStyle` option
Enforces either `string` or `symbol` for shared example names.
Checks for consistent style for shared example names.

def new_checker(ast_node)

def new_checker(ast_node)
  if style == :symbol
    SymbolChecker.new(ast_node)
  else # string
    StringChecker.new(ast_node)
  end
end

def offense?(ast_node)

def offense?(ast_node)
  if style == :symbol
    ast_node.str_type?
  else # string
    ast_node.sym_type?
  end
end

def on_send(node)

def on_send(node)
  shared_examples(node) do |ast_node|
    next unless offense?(ast_node)
    checker = new_checker(ast_node)
    add_offense(ast_node, message: checker.message) do |corrector|
      corrector.replace(ast_node, checker.preferred_style)
    end
  end
end