Sha256: 56c7ad2a172f80e385a3bf0c5ada407b80ec9165de2478a303d5dc2a5b2d52d3
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module RSpec # Checks for multiple top-level example groups. # # Multiple descriptions for the same class or module should either # be nested or separated into different test files. # # @example # # bad # describe MyClass, '.do_something' do # end # describe MyClass, '.do_something_else' do # end # # # good # describe MyClass do # describe '.do_something' do # end # describe '.do_something_else' do # end # end class MultipleDescribes < Base include RuboCop::RSpec::TopLevelGroup MSG = 'Do not use multiple top-level example groups - '\ 'try to nest them.' def on_top_level_group(node) top_level_example_groups = top_level_groups.select(&method(:example_group?)) return if top_level_example_groups.one? return unless top_level_example_groups.first.equal?(node) add_offense(node.send_node) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems