views:

231

answers:

2

How to test OpenID in rails with cucumber. Does anybody have real example? For example by using Fakeweb. Thank's

+1  A: 

I assume you don't want to test against a real OpenID provider so you'd probably need to create a fake of some sort. Or maybe stub the OpenID mechanism so that you can choose the execution path through your code by having it return different canned responses for different tests.

In terms of using Cucumber with Rails, Webrat is considered the standard way of faking a request through the web stack - it is pretty powerful and results in nice readable step definitions. Take a look at these links for further details:

tobyclemson
Thank's for answer. For cucumber testing I use webrat. Fake OpenID connection is what I want to do. It is posible to use Fakeweb library to create fake http reply. But it seems this is not easy. It seem there are more replies from OpenID server. It is not working for me. I don't know how to test comunication between rails app and openid server.
boblin
All you need to test is that your application responds in the correct way to any response that the OpenID provider gives. As such, it makes sense to replace the class in your application that talks to the OpenID provider with a stub and by returning the equivalent of a call to the OpenID provider for the methods on that class that you are using, you are effectively replicating the functionality of the OpenID provider without ever sending any real requests.
tobyclemson
A: 

I found this blog post that explains how to use Ruby OpenID Test Server (ROTS) as a local open id server for running integration tests against.

There is also a related question - How do I fake OpenID login in RSpec user story/Cucumber when using open_id_authentication plugin

tpower