lib/rubocop/cop/rspec/message_expectation.rb in rubocop-rspec-1.20.1 vs lib/rubocop/cop/rspec/message_expectation.rb in rubocop-rspec-1.21.0

- old
+ new

@@ -25,11 +25,11 @@ # expect(foo).to receive(:bar) # class MessageExpectation < Cop include ConfigurableEnforcedStyle - MSG = 'Prefer `%s` for setting message expectations.'.freeze + MSG = 'Prefer `%<style>s` for setting message expectations.'.freeze SUPPORTED_STYLES = %w[allow expect].freeze def_node_matcher :message_expectation, <<-PATTERN (send $(send nil? {:expect :allow} ...) :to #receive_message?) @@ -39,10 +39,11 @@ def on_send(node) message_expectation(node) do |match| return correct_style_detected if preferred_style?(match) - add_offense(match, location: :selector, message: MSG % style) do + message = format(MSG, style: style) + add_offense(match, location: :selector, message: message) do opposite_style_detected end end end