Class: RuboCop::Cop::RSpec::ContextWording
- Defined in:
- lib/rubocop/cop/rspec/context_wording.rb
Overview
Checks that `context` docstring starts with an allowed prefix.
The default list of prefixes is minimal. Users are encouraged to tailor the configuration to meet project needs. Other acceptable prefixes may include `if`, `unless`, `for`, `before`, `after`, or `during`. They may consist of multiple words if desired.
Constant Summary collapse
- MSG =
'Start context description with %<prefixes>s.'
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#context_wording(node) ⇒ Object
42 43 44 |
# File 'lib/rubocop/cop/rspec/context_wording.rb', line 42 def_node_matcher :context_wording, <<-PATTERN (block (send #rspec? { :context :shared_context } $(str #bad_prefix?) ...) ...) PATTERN |
#on_block(node) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/rubocop/cop/rspec/context_wording.rb', line 46 def on_block(node) context_wording(node) do |context| add_offense(context, message: format(MSG, prefixes: joined_prefixes)) end end |