234: def add_model_methods(mock, model_class, id, location)
235: container = mock.flexmock_container
236:
237: mock_errors = container.flexmock("errors")
238: mock_errors.flexmock_define_expectation(location, :count).and_return(0).by_default
239: mock_errors.flexmock_define_expectation(location, :full_messages).and_return([]).by_default
240:
241: mock.flexmock_define_expectation(location, :id).and_return(id).by_default
242: mock.flexmock_define_expectation(location, :to_params).and_return(id.to_s).by_default
243: mock.flexmock_define_expectation(location, :new_record?).and_return(false).by_default
244: mock.flexmock_define_expectation(location, :class).and_return(model_class).by_default
245: mock.flexmock_define_expectation(location, :errors).and_return(mock_errors).by_default
246:
247:
248:
249: lambda { }
250: mock.flexmock_define_expectation(location, :is_a?).with(any).and_return { |other|
251: other == model_class
252: }.by_default
253: mock.flexmock_define_expectation(location, :instance_of?).with(any).and_return { |other|
254: other == model_class
255: }.by_default
256: mock.flexmock_define_expectation(location, :kind_of?).with(any).and_return { |other|
257: model_class.ancestors.include?(other)
258: }.by_default
259: end