# File lib/flexmock/partial_mock.rb, line 119
119:     def new_instances(*allocators, &block)
120:       fail ArgumentError, "new_instances requires a Class to stub" unless Class === @obj
121:       allocators = [:new] if allocators.empty?
122:       result = ExpectationRecorder.new
123:       allocators.each do |allocate_method|
124:         # HACK: Without the following lambda, Ruby 1.9 will not bind
125:         # the allocate_method parameter correctly.
126:         lambda { } 
127:         self.should_receive(allocate_method).and_return { |*args|
128:           new_obj = invoke_original(allocate_method, args)
129:           mock = flexmock_container.flexmock(new_obj)
130:           block.call(mock) if block_given?
131:           result.apply(mock)
132:           new_obj
133:         }
134:       end
135:       result
136:     end