Class: RuboCop::Cop::RSpec::MissingExampleGroupArgument

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/rspec/missing_example_group_argument.rb

Overview

Checks that the first argument to an example group is not empty.

Examples:

# bad
describe do
end

RSpec.describe do
end

# good
describe TestedClass do
end

describe "A feature example" do
end

Constant Summary collapse

MSG =
'The first argument to `%<method>s` should not be empty.'

Constants inherited from Cop

Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE

Constants included from RSpec::Language

RSpec::Language::ALL, RSpec::Language::RSPEC

Instance Method Summary collapse

Methods inherited from Cop

inherited, #relevant_file?

Instance Method Details

#on_block(node) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rubocop/cop/rspec/missing_example_group_argument.rb', line 25

def on_block(node)
  return unless example_group?(node)
  return if node.send_node.arguments?

  add_offense(node, location: :expression,
                    message: format(MSG, method: node.method_name))
end