ruby on rails - Asking rspec to stub find(1), instead it's encountering find(1, {:conditions=>nil}) -
i'm telling rspec:
@foo1 = factory(:foo) @foo2 = factory(:foo) foo.stub(:find).with(@foo1.id){@foo1} foo.stub(:find).with(@foo2.id){@foo2}
as spec code:
f = foo.find(foo_id)
and error:
expected: (1) got: (1, {:conditions=>nil})
i thought perhaps stub can't told parameters expect, , have use should_receive
, though that's not behavior i'm testing in spec -- tried , has same error.
i think you're missing something. stub returns canned response don't have retrieve data database. still need expectation on own code.
#in spec... @foo = mock(foo) foo.stub!(:find).and_return(@foo) #...do stuff calls foo.find... x.should be_y
of course, can use fixtures seed test database, don't have mock activerecord @ all...
Comments
Post a Comment