Michael Barton
Michael Barton

Reputation: 9566

What is the best way to test authlogic-open-id with cucumber and webrat?

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?

Upvotes: 3

Views: 785

Answers (2)

Michael Barton
Michael Barton

Reputation: 9566

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.

Upvotes: 1

MatthewFord
MatthewFord

Reputation: 2926

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).

Upvotes: 2

Related Questions