lib/rubocop/cop/rspec/message_expectation.rb in rubocop-rspec-2.2.0 vs lib/rubocop/cop/rspec/message_expectation.rb in rubocop-rspec-2.3.0
- old
+ new
@@ -30,13 +30,15 @@
MSG = 'Prefer `%<style>s` for setting message expectations.'
SUPPORTED_STYLES = %w[allow expect].freeze
RESTRICT_ON_SEND = %i[to].freeze
+ # @!method message_expectation(node)
def_node_matcher :message_expectation, <<-PATTERN
(send $(send nil? {:expect :allow} ...) :to #receive_message?)
PATTERN
+ # @!method receive_message?(node)
def_node_search :receive_message?, '(send nil? :receive ...)'
def on_send(node)
message_expectation(node) do |match|
return correct_style_detected if preferred_style?(match)