Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Faking out redirects
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mike Doel  
View profile  
 More options Sep 30 2009, 4:39 pm
From: Mike Doel <m...@mikedoel.com>
Date: Wed, 30 Sep 2009 13:39:30 -0700 (PDT)
Local: Wed, Sep 30 2009 4:39 pm
Subject: Faking out redirects
Trying on both the Cuke and FakeWeb list.  Any help is appreciated...

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, so we have:

FakeWeb.allow_net_connect=false

set.  I've tried to write a scenario like this...

 Scenario: Submit valid payment data using default address
  Given FakeWeb will mimic a braintree success
    And I am ready to transact
   When I select "VISA" from "Card Type"
    And I fill in "Card Number" with "4111111111111111"
    And I press "Continue"
   Then I should see "Woo - Billing!"

with a step like:

 Given /^FakeWeb will mimic a braintree success$/ do
   FakeWeb.register_uri :post,'https://
secure.braintreepaymentgateway.com/api/transact.php',
                        :status => ["301", "Moved Permanently"],
                        :location => transaction_success_url
(Transaction.last)
 end

The URL in the above step of course matches the first parameter to the
form_tag in the view.  However, when I try executing this, I get the
error:

No route matches "/api/transact.php" with {:method=>:post}
(ActionController::RoutingError)
(eval):2:in `click_button'

Can anyone suggest what the right way to mock out the network would be
for a case like this?  I had thought the above FakeWeb call would
result in the "I press 'Continue'" step getting redirected as
mentioned above, but the error looks like it never even gets to
FakeWeb.

Any help/suggestions would be appreciated.

Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Parker  
View profile  
 More options Sep 30 2009, 5:23 pm
From: Matt Parker <moonmaster9...@gmail.com>
Date: Wed, 30 Sep 2009 17:23:34 -0400
Local: Wed, Sep 30 2009 5:23 pm
Subject: Re: [fakeweb] Faking out redirects

it may be hitting fakeweb looking for a mocked request like
"/api/transact.php" instead of "
https://secure.braintreepaymentgateway.com/api/transact.php". when fakeweb
says it doesn't have any mocks like that, it then goes to the rails app and
the router bails out saying that it doesn't match a route. try mocking

 Given /^FakeWeb will mimic a braintree success$/ do
  FakeWeb.register_uri
:post,'/api/transact.php<http://secure.braintreepaymentgateway.com/api/transact.php>
',
     :status => ["301", "Moved Permanently"],
     :location => transaction_success_url(Transaction.last)
 end


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Kampmeier  
View profile  
 More options Sep 30 2009, 8:33 pm
From: Chris Kampmeier <ch...@kampers.net>
Date: Wed, 30 Sep 2009 17:33:09 -0700
Local: Wed, Sep 30 2009 8:33 pm
Subject: Re: [fakeweb] Faking out redirects

On Wed, Sep 30, 2009 at 1:39 PM, Mike Doel <m...@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? I'm not sure where that code lives, but we could go find
out.

We use Cucumber for acceptance testing and want our Feature/Scenarios

> to run without requiring a network connection

So now I'm curious, does this work without FakeWeb (i.e. hitting the
external service)? If not, you'd have to fix that first. If it does work,
then that's good -- we can probably figure out how to stub it. Let me know!

Chris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Patterson  
View profile  
 More options Oct 1 2009, 3:38 am
From: Matt Patterson <m...@reprocessed.org>
Date: Thu, 1 Oct 2009 08:38:56 +0100
Local: Thurs, Oct 1 2009 3:38 am
Subject: Re: [fakeweb] Re: Faking out redirects
On 1 Oct 2009, at 01:33, Chris Kampmeier wrote:

> On Wed, Sep 30, 2009 at 1:39 PM, Mike Doel <m...@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
   <m...@reprocessed.org> | http://www.reprocessed.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »