Class: RuboCop::Cop::RSpec::Pending

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

Overview

Checks for any pending or skipped examples.

Examples:

# bad
describe MyClass do
  it "should be true"
end

describe MyClass do
  it "should be true", skip: true do
    expect(1).to eq(2)
  end
end

describe MyClass do
  it "should be true" do
    pending
  end
end

describe MyClass do
  xit "should be true" do
  end
end

# good
describe MyClass do
end

Constant Summary collapse

MSG =
'Pending spec found.'

Instance Method Summary collapse

Methods included from SkipOrPending

#skip_or_pending_inside_block?, #skipped_in_metadata?

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_send(node) ⇒ Object



61
62
63
64
65
# File 'lib/rubocop/cop/rspec/pending.rb', line 61

def on_send(node)
  return unless pending_block?(node) || skipped?(node)

  add_offense(node)
end

#pending_block?(node) ⇒ Object



54
55
56
57
58
59
# File 'lib/rubocop/cop/rspec/pending.rb', line 54

def_node_matcher :pending_block?, "{\n  (send #rspec? #ExampleGroups.skipped ...)\n  (send nil? {#Examples.skipped #Examples.pending} ...)\n}\n"

#skippable?(node) ⇒ Object



41
42
43
44
45
46
# File 'lib/rubocop/cop/rspec/pending.rb', line 41

def_node_matcher :skippable?, "{\n  (send #rspec? #ExampleGroups.regular ...)\n  #skippable_example?\n}\n"

#skippable_example?(node) ⇒ Object



49
50
51
# File 'lib/rubocop/cop/rspec/pending.rb', line 49

def_node_matcher :skippable_example?, "(send nil? #Examples.regular ...)\n"