Class: RuboCop::Cop::RSpec::ExpectInHook
- Defined in:
- lib/rubocop/cop/rspec/expect_in_hook.rb
Overview
Do not use ‘expect` in hooks such as `before`.
Constant Summary collapse
- MSG =
'Do not use `%<expect>s` in `%<hook>s` hook'.freeze
- HOOKS =
Hooks::ALL.node_pattern_union.freeze
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#on_block(node) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/rubocop/cop/rspec/expect_in_hook.rb', line 38 def on_block(node) hook(node) do |hook_name, body| expect(body) do |expect| method = send_node(expect) add_offense(method, location: :selector, message: (method, hook_name)) end end end |