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

Inherits:
Base
  • 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.'

Instance Method Summary collapse

Methods inherited from Base

inherited, #on_new_investigation

Methods included from RSpec::Language::NodePattern

#block_pattern, #send_pattern

Instance Method Details

#on_block(node) ⇒ Object


25
26
27
28
29
30
# 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, message: format(MSG, method: node.method_name))
end