lib/rubocop/cop/rspec/expect_in_hook.rb in rubocop-rspec-2.12.1 vs lib/rubocop/cop/rspec/expect_in_hook.rb in rubocop-rspec-2.13.0

- old
+ new

@@ -18,24 +18,27 @@ # # # good # it do # expect(something).to eq 'foo' # end + # class ExpectInHook < Base MSG = 'Do not use `%<expect>s` in `%<hook>s` hook' # @!method expectation(node) def_node_search :expectation, send_pattern('#Expectations.all') - def on_block(node) + def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless hook?(node) return if node.body.nil? expectation(node.body) do |expect| add_offense(expect.loc.selector, message: message(expect, node)) end end + + alias on_numblock on_block private def message(expect, hook) format(MSG, expect: expect.method_name, hook: hook.method_name)