Sha256: 8b5fd32587b49861679fbd3ff4b7c0f49c8e0106bd94e795d0c319c10f25d119

Contents?: true

Size: 1021 Bytes

Versions: 12

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RSpec
      # Checks for multiple top level describes.
      #
      # 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 < Cop
        include RuboCop::RSpec::TopLevelDescribe

        MSG = 'Do not use multiple top level describes - '\
              'try to nest them.'

        def on_top_level_describe(node, _args)
          return if single_top_level_describe?
          return unless top_level_nodes.first.equal?(node)

          add_offense(node)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubocop-rspec-1.42.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.41.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.40.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.39.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.38.1 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.38.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.37.1 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.37.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.36.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.35.0 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.34.1 lib/rubocop/cop/rspec/multiple_describes.rb
rubocop-rspec-1.34.0 lib/rubocop/cop/rspec/multiple_describes.rb