class FlexMock::CompositeExpectation
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.
Public Class Methods
Source
# File lib/flexmock/composite_expectation.rb, line 9 def initialize @expectations = [] end
Initialize the composite expectation.
Public Instance Methods
Source
# File lib/flexmock/composite_expectation.rb, line 14 def add(expectation) @expectations << expectation end
Add an expectation to the composite.
Source
# File lib/flexmock/composite_expectation.rb, line 19 def method_missing(sym, *args, **kw, &block) @expectations.each do |expectation| expectation.send(sym, *args, **kw, &block) end self end
Apply the constraint method to all expectations in the composite.
Source
# File lib/flexmock/composite_expectation.rb, line 35 def mock @expectations.first.mock end
Return the associated mock object.
Source
# File lib/flexmock/composite_expectation.rb, line 30 def order_number @expectations.first.order_number end
Return the order number of the first expectation in the list.
Source
# File lib/flexmock/composite_expectation.rb, line 41 def should_receive(*args, **kw, &block) @expectations.first.mock. flexmock_define_expectation(caller, *args, **kw, &block) end
Start a new method expectation. The following constraints will be applied to the new expectation.
Source
# File lib/flexmock/composite_expectation.rb, line 47 def to_s if @expectations.size > 1 "[" + @expectations.collect { |e| e.to_s }.join(', ') + "]" else @expectations.first.to_s end end
Return a string representations