Class: RuboCop::Cop::RSpec::ExpectInLet
- Defined in:
- lib/rubocop/cop/rspec/expect_in_let.rb
Overview
Do not use ‘expect` in let.
Constant Summary collapse
- MSG =
'Do not use `%<expect>s` in let'
Instance Method Summary collapse
- #expectation(node) ⇒ Object
-
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler.
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#expectation(node) ⇒ Object
23 |
# File 'lib/rubocop/cop/rspec/expect_in_let.rb', line 23 def_node_search :expectation, '(send nil? #Expectations.all ...)' |
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler
25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/rspec/expect_in_let.rb', line 25 def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless let?(node) return if node.body.nil? expectation(node.body) do |expect| add_offense(expect.loc.selector, message: (expect)) end end |