Class: RuboCop::Cop::RSpec::RepeatedExample

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

Overview

Check for repeated examples within example groups.

Examples:


it 'is valid' do
  expect(user).to be_valid
end

it 'validates the user' do
  expect(user).to be_valid
end

Constant Summary collapse

MSG =
"Don't repeat examples within an example group."

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

rubocop:disable InternalAffairs/NumblockHandler



21
22
23
24
25
26
27
# File 'lib/rubocop/cop/rspec/repeated_example.rb', line 21

def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
  return unless example_group?(node)

  repeated_examples(node).each do |repeated_example|
    add_offense(repeated_example)
  end
end