Class: RuboCop::Cop::RSpec::FactoryBot::FactoryClassName
- Defined in:
- lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb
Overview
Use string value when setting the class attribute explicitly.
Constant Summary collapse
- MSG =
"Pass '%<class_name>s' instead of %<class_name>s."
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
RSpec::Language::ALL, RSpec::Language::RSPEC
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#autocorrect(node) ⇒ Object
30 31 32 33 34 |
# File 'lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb', line 30 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.expression, "'#{node.source}'") end end |
#on_send(node) ⇒ Object
24 25 26 27 28 |
# File 'lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb', line 24 def on_send(node) class_name(node) do |cn| add_offense(cn, message: format(MSG, class_name: cn.const_name)) end end |