[rspec-users] authentication mocks
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.
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
> 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).
> Jonathan Linowes wrote:
>> 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?
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> rspec-users mailing list
> rspec-users at rubyforge.org
sross at calicowebdev.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users