hi everyone! i ve been working in my new rspec scaffold generator. I have made all the neccesary specs over all controllers and models. I am working with restful_authenticated plugin. I have already coded the spects of it too. But now im trying to test my controllers and i dont know the way to "jump" my authentication system when i run rake spec. The errors described are reffered to this plugin and i would like to ignore it. I think the solution might be mocking the user and turning "true" to the login? method... i have tryied with the login? method and nothing happened. Am i in the right way? have anybody had this problem before? Thanks a lot. Marcio.
On Jul 1, 2008, at 12:59 PM, marcio <marcio.rails at gmail.com> wrote:> hi everyone! i ve been working in my new rspec scaffold generator. > I have made all the neccesary specs over all controllers and models. > I am working with restful_authenticated plugin. I have already coded > the spects of it too. But now im trying to test my controllers and i > dont know the way to "jump" my authentication system when i run rake > spec. The errors described are reffered to this plugin and i would > like to ignore it. > I think the solution might be mocking the user and turning "true" to > the login? method... i have tryied with the login? method and nothing > happened. Am i in the right way? > have anybody had this problem before?Mocking the user sounds like the right approach. If you post some code we can help you more specifically. Cheers, David> > > Thanks a lot. > > Marcio. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On Tue, Jul 1, 2008 at 11:08 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Jul 1, 2008, at 12:59 PM, marcio <marcio.rails at gmail.com> wrote: > >> hi everyone! i ve been working in my new rspec scaffold generator. >> I have made all the neccesary specs over all controllers and models. >> I am working with restful_authenticated plugin. I have already coded >> the spects of it too. But now im trying to test my controllers and i >> dont know the way to "jump" my authentication system when i run rake >> spec. The errors described are reffered to this plugin and i would >> like to ignore it. >> I think the solution might be mocking the user and turning "true" to >> the login? method... i have tryied with the login? method and nothing >> happened. Am i in the right way? >> have anybody had this problem before? > > Mocking the user sounds like the right approach. If you post some code we > can help you more specifically. > > Cheers, > David >I used to do it like @controller.stub!(:login_required) @controller.stub!(:current_user).and_return mock_model(User) is this still valid?