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.
Add an expectation to the composite.
# File lib/flexmock/expectation.rb, line 407 def add(expectation) @expectations << expectation end
Apply the constraint method to all expectations in the composite.
# File lib/flexmock/expectation.rb, line 412 def method_missing(sym, *args, &block) @expectations.each do |expectation| expectation.send(sym, *args, &block) end self end
Return the associated mock object.
# File lib/flexmock/expectation.rb, line 428 def mock @expectations.first.mock end
Return the order number of the first expectation in the list.
# File lib/flexmock/expectation.rb, line 423 def order_number @expectations.first.order_number end
Start a new method expectation. The following constraints will be applied to the new expectation.
# File lib/flexmock/expectation.rb, line 434 def should_receive(*args, &block) @expectations.first.mock.should_receive(*args, &block) end
Return a string representations
# File lib/flexmock/expectation.rb, line 439 def to_s if @expectations.size > 1 "[" + @expectations.collect { |e| e.to_s }.join(', ') + "]" else @expectations.first.to_s end end
Initialize the composite expectation.
# File lib/flexmock/expectation.rb, line 402 def initialize @expectations = [] end