Class: RuboCop::Cop::RSpec::ContextWording

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

Overview

‘context` block descriptions should start with ’when’, or ‘with’.

‘without’

Prefixes:
  - when
  - with
  - without
  - if

Examples:

‘Prefixes` configuration option, defaults: ’when’, ‘with’, and


# bad
context 'the display name not present' do
  # ...
end

# good
context 'when the display name is not present' do
  # ...
end

See Also:

Constant Summary collapse

MSG =
'Start context description with %<prefixes>s.'

Constants inherited from Cop

RuboCop::Cop::RSpec::Cop::DEFAULT_CONFIGURATION, RuboCop::Cop::RSpec::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



36
37
38
39
40
# File 'lib/rubocop/cop/rspec/context_wording.rb', line 36

def on_block(node)
  context_wording(node) do |context|
    add_offense(context, message: message)
  end
end