Class: RuboCop::Cop::RSpec::VoidExpect
- Defined in:
- lib/rubocop/cop/rspec/void_expect.rb
Overview
Checks void ‘expect()`.
Constant Summary collapse
- MSG =
'Do not use `expect()` without `.to` or `.not_to`. ' \ 'Chain the methods or remove it.'
- RESTRICT_ON_SEND =
%i[expect].freeze
Instance Method Summary collapse
- #expect?(node) ⇒ Object
- #expect_block?(node) ⇒ Object
-
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler.
- #on_send(node) ⇒ Object
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
#block_or_numblock_pattern, #block_pattern, #numblock_pattern, #send_pattern
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
#expect?(node) ⇒ Object
21 22 23 |
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 21 def_node_matcher :expect?, <<~PATTERN (send nil? :expect ...) PATTERN |
#expect_block?(node) ⇒ Object
26 27 28 |
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 26 def_node_matcher :expect_block?, <<~PATTERN (block #expect? (args) _body) PATTERN |
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler
36 37 38 39 40 |
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 36 def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless expect_block?(node) check_expect(node) end |
#on_send(node) ⇒ Object
30 31 32 33 34 |
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 30 def on_send(node) return unless expect?(node) check_expect(node) end |