A composite expectation allows several expectations to be grouped into a single composite and then apply the same constraints to all expectations in the group.
Methods
Public Class methods
Initialize the composite expectation.
[ show source ]
# File lib/flexmock/expectation.rb, line 402
402: def initialize
403: @expectations = []
404: end
Public Instance methods
Add an expectation to the composite.
[ show source ]
# File lib/flexmock/expectation.rb, line 407
407: def add(expectation)
408: @expectations << expectation
409: end
Apply the constraint method to all expectations in the composite.
[ show source ]
# File lib/flexmock/expectation.rb, line 412
412: def method_missing(sym, *args, &block)
413: @expectations.each do |expectation|
414: expectation.send(sym, *args, &block)
415: end
416: self
417: end
Return the associated mock object.
[ show source ]
# File lib/flexmock/expectation.rb, line 428
428: def mock
429: @expectations.first.mock
430: end
Return the order number of the first expectation in the list.
[ show source ]
# File lib/flexmock/expectation.rb, line 423
423: def order_number
424: @expectations.first.order_number
425: end
[ show source ]
# File lib/flexmock/expectation.rb, line 434
434: def should_receive(*args, &block)
435: @expectations.first.mock.should_receive(*args, &block)
436: end
Return a string representations
[ show source ]
# File lib/flexmock/expectation.rb, line 439
439: def to_s
440: if @expectations.size > 1
441: "[" + @expectations.collect { |e| e.to_s }.join(', ') + "]"
442: else
443: @expectations.first.to_s
444: end
445: end