Class: RuboCop::Cop::RSpec::SharedExamples::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/shared_examples.rb

Overview

:nodoc:

Constant Summary collapse

MSG =
'Prefer %<prefer>s over `%<current>s` ' \
'to titleize shared examples.'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Checker

Returns a new instance of Checker.



50
51
52
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 50

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



49
50
51
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 49

def node
  @node
end

Instance Method Details

#messageObject



54
55
56
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 54

def message
  format(MSG, prefer: preferred_style, current: symbol.inspect)
end

#preferred_styleObject



58
59
60
61
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 58

def preferred_style
  string = symbol.to_s.tr('_', ' ')
  wrap_with_single_quotes(string)
end