Class: RuboCop::Cop::RSpec::SharedExamples::StringChecker

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) ⇒ StringChecker

Returns a new instance of StringChecker.



110
111
112
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 110

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



108
109
110
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 108

def node
  @node
end

Instance Method Details

#messageObject



114
115
116
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 114

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

#preferred_styleObject



118
119
120
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 118

def preferred_style
  "'#{node.value.to_s.tr('_', ' ')}'"
end