Sha256: 8010939865c08852e8ded19316e1adb6eb895e6dde5701e4523579fa8d56a357
Contents?: true
Size: 986 Bytes
Versions: 1
Compression:
Stored size: 986 Bytes
Contents
module RuboCop module Cop module RSpec # Check for repeated examples within example groups. # # @example # # it 'is valid' do # expect(user).to be_valid # end # # it 'validates the user' do # expect(user).to be_valid # end # class RepeatedExample < Cop MSG = "Don't repeat examples within an example group.".freeze def on_block(node) return unless example_group?(node) repeated_examples(node).each do |repeated_example| add_offense(repeated_example, :expression) end end private def repeated_examples(node) RuboCop::RSpec::ExampleGroup.new(node) .examples .group_by { |example| [example.metadata, example.implementation] } .values .reject(&:one?) .flatten .map(&:to_node) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.10.0 | lib/rubocop/cop/rspec/repeated_example.rb |