Sam King
Sam King

Reputation: 2188

Using Cucumber to test my OAuth provider in Rails

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

Upvotes: 1

Views: 1686

Answers (1)

Jordan Brock
Jordan Brock

Reputation: 141

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.

Upvotes: 2

Related Questions