Displaying 3 results from an estimated 3 matches for "jamesthepiper".
2007 Feb 06
3
Using any_instance with Rails to make sure the right thing is saved?
I''d like to test that an object with the correct attributes is saved,
something like:
def test_create_without_existing_suite
this = self
w = Annotation.any_instance.expects(:save).with do |x|
this.assert_equal ''fnord'',
some_way_get_the_name_of_the_receiver_of_save
true
end
w.returns true
end
But the object is created inside the method
2007 Mar 03
11
Beyond multiple return values
First off, I love mocha and have been using it all over the place
ever since I found it a few months ago.
So I noticed the other day rather belatedly that mocha-0.4.0 had been
released and that we can now do the object.stubs(:method).returns
(:first_value, :second_value). Much neater than fiddling with lambdas
everytime this sort of behaviour is needed
But can we go further ? I was
2007 Mar 18
5
Automatically mocking ActiveRecord methods
Seems like I do a fair amount of mocking ActiveRecord''s automatically
generated routines when I''m testing controllers. Things like:
@portalspace = PortalSpace.new :public_readable => true,
:public_writable => true, :name => ''public''
@portalspace.stubs(:id).returns(203)
PortalSpace.stubs(:find).with(203).returns(@portalspace)