Class: RuboCop::Cop::RSpec::DescribeClass

Inherits:
RuboCop::Cop show all
Includes:
RSpec::SpecOnly, RSpec::TopLevelDescribe
Defined in:
lib/rubocop/cop/rspec/describe_class.rb

Overview

Check that the first argument to the top level describe is a constant.

Examples:

# bad
describe 'Do something' do
end

# good
describe TestedClass do
end

describe "A feature example", type: :feature do
end

Constant Summary collapse

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

Constants included from RSpec::SpecOnly

RSpec::SpecOnly::DEFAULT_CONFIGURATION

Instance Method Summary collapse

Methods included from RSpec::SpecOnly

#relevant_file?

Methods included from RSpec::TopLevelDescribe

#on_send

Instance Method Details

#on_top_level_describe(node, args) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/rubocop/cop/rspec/describe_class.rb', line 42

def on_top_level_describe(node, args)
  return if valid_describe?(node)

  (node) do |pairs|
    return if pairs.any?(&method(:rails_metadata?))
  end

  add_offense(args.first, :expression)
end