Subject: [Cucumber:4039] [Capybara/Rack-Test] Integration testing external sites/redirects
Date: Saturday 10th April 2010 19:14:50 UTC (over 7 years ago)
I'm working on integrating my current project with braintree, which has an API that allows your users to submit their credit card details directly to them, where they are redirected back to your site, so as to avoid the security risks involved in dealing with the credit card data directly. It wasn't obvious how to write a cucumber scenario that does all this, so it was with great interest that I found this old thread about this very topic (involving braintree, too!). I came up with what I think is a pretty great solution, and was going to reply to that thread with it, but I noticed that the "reply" option is no longer available--apparently you can't resurrect old threads? (Probably a good thing, I guess). In case anyone else has this issue, I wanted to share my solution. The underlying problem is that rack-test makes all requests to your rack app, even when processing a form submission to an entirely different domain. Luckily, the modularity of rack allows you to swap our your rack app with any other rack app, and the rack-client gem provides a rack app that simply delegates to Net::HTTP under the covers. So, you simply swap out your rack app with a Rack::Client instance before making a request to an external domain. My gist has the code I use for this. I'm also using FakeWeb and my VCR gem to handle recording and replaying the Net::HTTP requests so my scenarios are fast and deterministic. Myron  http://groups.google.com/group/cukes/browse_thread/thread/524e0f0bdd74e577/ddb701f6a3e1934b  http://github.com/halorgium/rack-client  http://gist.github.com/362227 -- You received this message because you are subscribed to the Google Groups "Cukes" group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To unsubscribe from this group, send email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit this group at http://groups.google.com/group/cukes?hl=en.