class RuboCop::Cop::Salsify::RspecStringLiterals
This cop checks if quotes match the configured preference. It is intended to be use specifically for specs and in combination with Salsify/RspecDocString.
Used together with Salsify/RspecDocString it allows one quote style to be used for doc strings (‘describe “foobar”`) and another style to be used for all other strings in specs.
Constants
- DOCUMENTED_METHODS
- DOUBLE_QUOTE_MSG
- SINGLE_QUOTE_MSG
Public Instance Methods
Source
# File lib/rubocop/cop/salsify/rspec_string_literals.rb, line 27 def autocorrect(corrector, node) StringLiteralCorrector.correct(corrector, node, style) end
Private Instance Methods
Source
# File lib/rubocop/cop/salsify/rspec_string_literals.rb, line 45 def documented_parent?(node) parent = node.parent parent && parent.send_type? && DOCUMENTED_METHODS.include?(parent.children[1]) end
Source
# File lib/rubocop/cop/salsify/rspec_string_literals.rb, line 33 def message(_node) style == :single_quotes ? SINGLE_QUOTE_MSG : DOUBLE_QUOTE_MSG end
Source
# File lib/rubocop/cop/salsify/rspec_string_literals.rb, line 38 def offense?(node) return false if documented_parent?(node) return false if inside_interpolation?(node) wrong_quotes?(node) end
Share implementation with Style/StringLiterals from rubocop