Sha256: 89d250aa83154d97413381ae11514dcbe3aef83c0bf859ff49af2d504a9b3158

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    # 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 RSpecDescribeClass < Cop
      include 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rspec-1.0.rc2 lib/rubocop/cop/rspec_describe_class.rb
rubocop-rspec-1.0.rc1 lib/rubocop/cop/rspec_describe_class.rb