Class: Crspec::Mock::ReceiveMessagesMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/crspec/mock/double.rb

Overview

allow(target).to receive_messages(a: 1, b: 2)

Instance Method Summary collapse

Constructor Details

#initialize(messages) ⇒ ReceiveMessagesMatcher

Returns a new instance of ReceiveMessagesMatcher.



328
329
330
# File 'lib/crspec/mock/double.rb', line 328

def initialize(messages)
  @messages = messages
end

Instance Method Details

#setup_allow(target) ⇒ Object



332
333
334
335
336
# File 'lib/crspec/mock/double.rb', line 332

def setup_allow(target)
  @messages.map do |method_name, value|
    StubChain.new(target, method_name).and_return(value)
  end
end

#setup_expect(target) ⇒ Object



338
339
340
341
342
# File 'lib/crspec/mock/double.rb', line 338

def setup_expect(target)
  @messages.map do |method_name, value|
    ExpectationChain.new(target, method_name).and_return(value)
  end
end