Sha256: 39004aa42fdb6d75d82eb04452393f3bff6d6fba9c3baae5013dafb166536afd

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module RSpec
      # Check that the first argument to the top level describe is the tested
      # class or module.
      #
      # @example
      #   # bad
      #   describe 'Do something' do
      #   end
      #
      #   # good
      #   describe TestedClass do
      #   end
      class DescribeClass < Cop
        include RuboCop::RSpec::TopLevelDescribe

        MESSAGE = 'The first argument to describe should be the class or ' \
                  'module being tested.'

        def on_top_level_describe(_node, args)
          return if args.first && args.first.type == :const
          add_offense(args.first, :expression, MESSAGE)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-rspec-1.2.2 lib/rubocop/cop/rspec/describe_class.rb
rubocop-rspec-1.2.1 lib/rubocop/cop/rspec/describe_class.rb
rubocop-rspec-1.2.0 lib/rubocop/cop/rspec/describe_class.rb
rubocop-rspec-1.1.0 lib/rubocop/cop/rspec/describe_class.rb
rubocop-rspec-1.0.1 lib/rubocop/cop/rspec/describe_class.rb
rubocop-rspec-1.0 lib/rubocop/cop/rspec/describe_class.rb
rubocop-rspec-1.0.rc3 lib/rubocop/cop/rspec/describe_class.rb