Class: RuboCop::Cop::Salsify::RspecDocString

Inherits:
RSpec::Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
ConfigurableEnforcedStyle
Defined in:
lib/rubocop/cop/salsify/rspec_doc_string.rb

Overview

Check that doc strings for example groups and examples use either single-quoted or double-quoted strings based on the enforced style.

Examples:


# When EnforcedStyle is double_quotes
# Good
it "does something" do
  ...
end

# When EnforcedStyle is single_quotes
# Good
it 'does something' do
  ...
end

Constant Summary collapse

SINGLE_QUOTE_MSG =
'Example Group/Example doc strings must be single-quoted.'
DOUBLE_QUOTE_MSG =
'Example Group/Example doc strings must be double-quoted.'
DOCUMENTED_METHODS =
[
  :context,
  :describe,
  :example,
  :example_group,
  :fcontext,
  :fdescribe,
  :feature,
  :fexample,
  :ffeature,
  :fit,
  :focus,
  :fscenario,
  :fspecify,
  :include_context,
  :include_examples,
  :it,
  :it_behaves_like,
  :it_should_behave_like,
  :its,
  :pending,
  :scenario,
  :shared_context,
  :shared_examples,
  :shared_examples_for,
  :skip,
  :specify,
  :xcontext,
  :xdescribe,
  :xexample,
  :xfeature,
  :xit,
  :xscenario,
  :xspecify
].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



77
78
79
80
81
82
# File 'lib/rubocop/cop/salsify/rspec_doc_string.rb', line 77

def on_send(node)
  _receiver, _method_name, *args = *node
  return unless documented_method?(node) && args.first&.str_type?

  check_quotes(args.first)
end