views:

73

answers:

1

I have a rails site that allows authentication through OAuth (I use Restful Authentication and the Rails OAuth Plugin). To make sure that it worked, I made a quick site to act as an OAuth consumer.

However, I want the testing to be self-contained in Cucumber features. Ideally, this would use Webrat so that Cucumber could correctly manage resetting the database on its own and so that I wouldn't need to run an instance of the server for the Cucumber tests to work. However, since the OAuth plugin (and the underlying gem) make the HTTP requests, I can't think of an easy way to go through Webrat without generating all of the requests on my own (writing the code from the OAuth gem into my cucumber test).

Any ideas?

Thanks

+1  A: 

While the article isn't about the OAuth plugin (it's about the TwitterAuth plugin, which is just OAuth, but relating specifically to twitter), http://blog.zerosum.org/2009/7/13/twitter-auth-integration-testing has a good overview of what you need to do.

Basically, you use a gem called FakeWeb to block out any external access, and fool cucumber into thinking it's talking to the external service.

Jordan Brock
Thanks -- it might be a little harder to fake a consumer than a provider, but it looks like this is what I needed.
Sam