Class: RuboCop::Cop::RSpec::SkipBlockInsideExample

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/skip_block_inside_example.rb

Overview

Checks for passing a block to ‘skip` within examples.

Examples:

# bad
it 'does something' do
  skip 'not yet implemented' do
    do_something
  end
end

# good
it 'does something' do
  skip 'not yet implemented'
  do_something
end

# good - when outside example
skip 'not yet implemented' do
end

Constant Summary collapse

MSG =
"Don't pass a block to `skip` inside examples."

Instance Method Summary collapse

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

#on_block(node) ⇒ Object Also known as: on_numblock



29
30
31
32
33
34
# File 'lib/rubocop/cop/rspec/skip_block_inside_example.rb', line 29

def on_block(node)
  return unless node.method?(:skip)
  return unless inside_example?(node)

  add_offense(node)
end