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_or_numblock_pattern, #block_pattern, #numblock_pattern, #send_pattern

Methods included from RSpec::Language

#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?

Instance Method Details

#on_block(node) ⇒ Object

rubocop:disable InternalAffairs/NumblockHandler



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

def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
  return unless example_group?(node)
  return if node.send_node.arguments?

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