I met a trouble: cannot do a form post to an outside website

now i use webrat for cucumber scenario testing. i have a page with a
form, which will post to a bank payment gateway. that is,

...

my scenario step script is:

==
And I press “confirm”

then I got such an error:

“No route matches “/pay/blablabla” with {:method=>:post}…”

i think webrat or rails ignore the “http://www.abank.com” prefix
automatically. and then i wrote a test script

==
get “http://www.abank.com/…”
puts response.body

yes, the test result proves the suspicion. i think it should be handled
in the rails testing layer. so, anybody can help me? thanks in advance.

Newman H. wrote:

now i use webrat for cucumber scenario testing. i have a page with a
form, which will post to a bank payment gateway. that is,

...

my scenario step script is:

==
And I press “confirm”

then I got such an error:

“No route matches “/pay/blablabla” with {:method=>:post}…”

i think webrat or rails ignore the “http://www.abank.com” prefix
automatically. and then i wrote a test script

==
get “http://www.abank.com/…”
puts response.body

yes, the test result proves the suspicion. i think it should be handled
in the rails testing layer. so, anybody can help me? thanks in advance.

I solved this problem by hacking webrat’s code. walking around the
requesting from webrat form, and then use Net::HTTP for a substitutor,

require ‘net/http’
require ‘uri’
require ‘nokogiri’

module Webrat
class Form
def submit
if !out_website?(form_action)
@session.request_page(form_action, form_method, params)
else
handle_outwebsite_action(form_action,params)
end
end

def handle_outwebsite_action(form_action,params)
  #...
end

end
end

require it before cucumbing.