On 10/6/07, Andrew WC Brown <[EMAIL PROTECTED]> wrote: > But what if I need to use posts as such? > > @person = mock_model(Person) > @person.stub_association!(:posts, :find_by_title => mock_model(Post)) > > posts.stub!(:count).and_return(2) > > _______________________________________________ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users >
Take a look at the source: you can pass in whatever methods you want to be stubbed. So, for example, @person.stub_association!(:posts, :find_by_title => mock_model(Post), :count => 2) Also, you should be able to stub after the fact like so: @person.posts.stub!(:count).and_return 2 Pat _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
