Class: RuboCop::Cop::RSpec::VoidExpect
- Inherits:
-
Base
- Object
- Base
- Base
- RuboCop::Cop::RSpec::VoidExpect
show all
- Defined in:
- lib/rubocop/cop/rspec/void_expect.rb
Overview
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
Methods inherited from Base
inherited, #on_new_investigation
#block_pattern, #send_pattern
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#expect?(node) ⇒ Object
20
21
22
|
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 20
def_node_matcher :expect?, <<-PATTERN
(send nil? :expect ...)
PATTERN
|
#expect_block?(node) ⇒ Object
25
26
27
|
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 25
def_node_matcher :expect_block?, <<-PATTERN
(block #expect? (args) _body)
PATTERN
|
#on_block(node) ⇒ Object
35
36
37
38
39
|
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 35
def on_block(node)
return unless expect_block?(node)
check_expect(node)
end
|
#on_send(node) ⇒ Object
29
30
31
32
33
|
# File 'lib/rubocop/cop/rspec/void_expect.rb', line 29
def on_send(node)
return unless expect?(node)
check_expect(node)
end
|