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::NodePattern

#block_pattern, #send_pattern

Instance Method Details

#on_block(node) ⇒ Object


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

def on_block(node)
  return unless example_group?(node)

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