################################################################# Helper methods for mock containers. MockContainer is a module that is designed to be mixed into other classes, particularly testing framework test cases. Since we don‘t want to pollute the method namespace of the class that mixes in MockContainer, a number of MockContainer methods were moved into ContainerHelper to to isoloate the names.

Methods
Included Modules
Constants
METHOD_NAME_RE = /^([A-Za-z_][A-Za-z0-9_]*[=!?]?|\[\]=?||\*\*|<<|>>|<=>|[<>=]=|=~|===|[-+]@|[-+\*\/%&^|<>~])$/
Public Instance methods
add_model_methods(mock, model_class, id)

Automatically add mocks for some common methods in ActiveRecord models.

     # File lib/flexmock/mock_container.rb, line 208
208:     def add_model_methods(mock, model_class, id)
209:       container = mock.flexmock_container
210:       mock.should_receive(
211:         :id => id,
212:         :to_params => id.to_s,
213:         :new_record? => false,
214:         :class => model_class,
215:         :errors => container.flexmock("errors", :count => 0))
216:       # HACK: Ruby 1.9 needs the following lambda so that model_class
217:       # is correctly bound below.
218:       lambda { }
219:       mock.should_receive(:is_a?).with(any).and_return { |other|
220:         other == model_class
221:       }
222:       mock.should_receive(:instance_of?).with(any).and_return { |other|
223:         other == model_class
224:       }
225:       mock.should_receive(:kind_of?).with(any).and_return { |other|
226:         model_class.ancestors.include?(other)
227:       }
228:     end
make_partial_proxy(container, obj, name, safe_mode)

Create a PartialMockProxy for the given object. Use name as the name of the mock object.

     # File lib/flexmock/mock_container.rb, line 232
232:     def make_partial_proxy(container, obj, name, safe_mode)
233:       name ||= "flexmock(#{obj.class.to_s})"
234:       obj.instance_eval {
235:         mock = FlexMock.new(name, container)
236:         @flexmock_proxy ||= PartialMockProxy.new(obj, mock, safe_mode)
237:       }
238:       obj.instance_variable_get("@flexmock_proxy")
239:     end
next_id()

Return the next id for mocked models.

     # File lib/flexmock/mock_container.rb, line 177
177:     def next_id
178:       @id_counter ||= 10000
179:       @id_counter += 1
180:     end