Class: RuboCop::Cop::RSpec::MessageExpectation
- Includes:
- ConfigurableEnforcedStyle
- Defined in:
- lib/rubocop/cop/rspec/message_expectation.rb
Overview
Checks for consistent message expectation style.
This cop can be configured in your configuration using the ‘EnforcedStyle` option and supports `–auto-gen-config`.
Constant Summary collapse
- MSG =
'Prefer `%<style>s` for setting message expectations.'
- SUPPORTED_STYLES =
%w[allow expect].freeze
Instance Method Summary collapse
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language::NodePattern
Instance Method Details
#on_send(node) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rubocop/cop/rspec/message_expectation.rb', line 40 def on_send(node) (node) do |match| return correct_style_detected if preferred_style?(match) = format(MSG, style: style) add_offense(match.loc.selector, message: ) do opposite_style_detected end end end |