开发者

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 Web开发者_开发技巧rat 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜