# 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:         check_allocate_method(allocate_method)
129:         # HACK: Without the following lambda, Ruby 1.9 will not bind
130:         # the allocate_method parameter correctly.
131:         lambda { }
132:         self.should_receive(allocate_method).and_return { |*args|
133:           new_obj = invoke_original(allocate_method, args)
134:           mock = flexmock_container.flexmock(new_obj)
135:           block.call(mock) if block_given?
136:           result.apply(mock)
137:           new_obj
138:         }
139:       end
140:       result
141:     end