Class: RuboCop::Cop::RSpec::SharedExamples::SymbolChecker

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 symbolize shared examples.'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ SymbolChecker

Returns a new instance of SymbolChecker.



90
91
92
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 90

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



88
89
90
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 88

def node
  @node
end

Instance Method Details

#messageObject



94
95
96
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 94

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

#preferred_styleObject



98
99
100
# File 'lib/rubocop/cop/rspec/shared_examples.rb', line 98

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