[rspec-users] Collection proxies need to be stubbed ?

Tobias Grimm listaccount at e-tobi.net
Sun Jan 21 06:25:30 EST 2007


Francois Beausoleil wrote:
> My question really boils down to:
> def index
>   @projects = current_user.projects.active
> end
> My spec needs to return the proxy, no ?  Here's my code:
>From a RSpec-newbie's point of view:

Looks like current_user is a method of the controller, that selects the
user from the request params, right? Mocking this means, current_user()
will not be covered by the specs. Normally I avoid mocking/stubbing
members of a class under test or private and protected members of any
class. You could instead mock the User class directly to return the User

But why not use fixtures and let it run with real data instead of
mocking the database away?



More information about the rspec-users mailing list