views:

591

answers:

2

I've been having trouble using cucumber and webrat to test authlogic-openid authentication in a rails app. Following Ryan Bates's excellent screencast I was able to install authlogic with the open-id plugin. OpenID works when I login using the browser but so far I've been unable to test the app using cucumber and webrat.

I've tried using rots as a dummy open id server. Again this works when I try it in the browser but webrat won't doesn't correctly follow the get/post redirects required to authentic with the dummy open id server.

This answer on SO suggests overriding the authentication method to always return a successful login but this approach doesn't seem like integration testing the application.

What is the best way to functionally test authlogic-open-id? Should I even bother? Should I test the actions when the user is already logged in and assume OpenID will work?

+2  A: 

have you tried the test helper set_session_for(@user)? I would assume that the plugin is tested and there really is no need to test it again (unless you have modified it).

MatthewFord
Thanks for your answer. I don't think it's possible to set session variables for webrat as it behaves as a browser viewing the website independent of the the testing code. Therefore ruby variables can't be passed to it. Also I'm not trying to test authlogic specifically but how my authentication systems works across the site as a whole.
Michael Barton
+1  A: 

I asked the same question on the authlogic mailing list. I got a good answer directing me to use WWW:Mechanise with some patch code to that makes webrat follow all redirects. This seems to work for doing rails integration testing using authlogic open id with a local open id server.

Here's the discussion thread.

Michael Barton