In our app, we're trying to mock out interaction with a third-party
payment processing service (Braintree in our case). The way
Braintree's transparent redirect model works is that the user form
posts credit card and other billing data to Braintree which redirects
the user back to our app to display the result.
We use Cucumber for acceptance testing and want our Feature/Scenarios
to run without requiring a network connection
> On Wed, Sep 30, 2009 at 1:39 PM, Mike Doel <mi...@mikedoel.com> wrote:
>> In our app, we're trying to mock out interaction with a third-party
>> payment processing service (Braintree in our case). The way
>> Braintree's transparent redirect model works is that the user form
>> posts credit card and other billing data to Braintree which redirects
>> the user back to our app to display the result.
>
> So, FakeWeb works by patching Net::HTTP. It sounds like the problem
> might be that submitting a form that has an external URI as the
> action doesn't use Net::HTTP. How that works is up to Webrat or the
> Rails integration testing stack (assuming you're using the usual
> Webrat/Rails stack and not celerity/selenium/etc.), and it looks
> like it might be ignoring the external domain entirely?
So, by default, Webrat uses Rails' integration tests, meaning any form
submissions / URL fetches (with the Webrat 'visit' command) ignore the
host/port entirely and just use the path part of the URL to inject
URLs into the routing dispatcher, meaning that FakeWeb will never get
a look-in
You could have a test-only route which does your redirect for you and
change the form submission URL in the test environment.
Or, you could switch to using Mechanise to perform actual HTTP
requests, in which case FakeWeb (if mechanise plays ball) will get a
look-in.
Matt
--
Matt Patterson | Design & Code
<ma...@reprocessed.org> | http://www.reprocessed.org/