views:

754

answers:

3
Given I have a rails app
And I'm using cucumber
And I'm using capybara
And I have an action that results in a redirect_to "http://some.other.domain.com/some_path"
When I test this action
Then the in-app portion of the test works fine
But I see this error: No route matches "/some_path" with {:method=>:get} (ActionController::RoutingError)

So capybara is properly redirected to "http://some.other.domain.com/some_path" but for some reason it thinks it should handle the path portion of the url inside my app. NOTE capybara has no problem at all with "http://some.other.domain.com/" -- my tests pass if I redirect to a url without a path portion.

Is this a bug?

A: 

Which driver are you using? The Rack-Test driver isn't going to allow you to request stuff from other domains. If Capybara is doing this with Selenium or Culerity, it's definitely a bug. If you want to help out in getting it fixed, writing a failing spec would be very appreciated :)

jnicklas
Interesting. I am using Rack-Test. I don't actually care to get the data back from the other domain (I'm using FakeWeb to fake my Net::Http requests that happen behind the scenes), I just want to ensure that I'm redirected to the proper url.I tried it with Culerity and Selenium. Selenium was fine, Culerity complained about receiving an image/gif on one of the visits.I'd really rather not have to use Selenium for this, it's so slow :)
joshsz
(I do have one controller action return an image/gif as part of a multi-app login tracking process, so the image is supposed to be there. I tried appending .gif to the url but culerity still barfs)
joshsz
A: 

I had a similar situation where I was integrating my app with the company's SSO platform. The way I got around this was to get the site running Selenium via appending the @javascript tag against the scenario.

+1  A: 

@javascript is a currently working solution, though there's also a mechanize driver in the works, which uses rack-test up to the point where you hit an external request.

It's a bit new and I haven't tried it yet, but am meaning to change my external @javascript tests to using it (tagged with @live or @external or similar) for the speed boost.

nruth
Take a look at [capybara's google group](http://groups.google.com/group/ruby-capybara) for discussion of this.
nruth