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