[rspec-users] authentication mocks
s.ross
cwdinfo at gmail.com
Wed May 30 11:33:21 EDT 2007
My observation is that mocking or stubbing as high in the API as
possible is best. So, if you have to dive into someone else's code,
your spec could break if their code breaks (e.g.,
restful_authentication). That's why Jerry's suggestion that you stub
your own filter is great.
Steve
On May 30, 2007, at 6:22 AM, Jerry West wrote:
> Hi Jonathan,
>
> You should be able to stub the routines a controller uses to check
> if a
> user is logged in, which will allow your controllers to function
> without
> actually requiring you to post login details. Something like
> 'controller.stub!(:logged_in?).and_return(true)' should suffice.
> Or you
> could stub the before_filter method itself. Check to see what your
> code calls behind the scenes. You may find you need to stub
> routines in
> the authentication module depending on what you want to spec (e.g.
> action on failing login, action on incorrect authorization, logging in
> via cookie, etc).
>
> Rgds,
> Jerry
>
>
>
> Jonathan Linowes wrote:
>> hi
>> I'm using restful_authentication
>> and have controller specs working using users fixtures (and login_as)
>>
>> however i've been trying for hours without success to do it without
>> fixtures, using mocks and stubs instead.
>>
>> anyone here done this? got code?
>> :)
>>
>> thanks
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
Steve Ross
sross at calicowebdev.com
http://www.calicowebdev.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070530/b8f8c22b/attachment-0001.html
More information about the rspec-users
mailing list