Webrat doesn't follow redirect because it considers the url external
Rails doesn't know which host it is running on. For generating links, it strips the hostname off the request URL, which can lead to errors when you have absolute URLs in your Cucumber tests.
If you really need to use absolute URLs somewhere, say in an email you send, either throw away the host when parsing it (e.g. body.scan(/http:\/\/[^\/]+\/([^\s"<]+)/)
) or tell Webrat you're back on your site.
Related cards:
Test redirects to an external URL with Cucumber/Capybara
When a controller action redirects to an external URL (like http://somehost.com/some/path
) you will find that this is hard to test with Cucumber and Capybara:
- A non-Javascript Rack::Test scenario will just ignore the host and try to open `/so...
Don't use PDFKit v0.5.4 – it breaks on dead urls
When I upgraded from 0.5.4 PDFKit deadlocked or crashed when an ApplicationController::RouteError occured. If this error happens only because of a broken image link you probably still wan't the page to render and get a PDF with a "missing image pl...
Don't follow Ajax requests with a redirect
The behaviour of browsers is very inconsistent when an Ajax request is answered with a redirect. Highlights are:
- IE 9 will follow a DELETE request with a second DELETE. You never want that.
- Firefox will follow a POST request with a GET, as yo...
Basement.org: On The Web, More Isn’t Only Less, It’s Actually Nothing
Amidst my 400 unread Boing Boing links are probably ten or fifteen that are probably real gems. But I’ll never know and Boing Boing sure as hell isn’t going to help me out.
The Ruby Object Model
In Ruby (almost) everything is an Object
. While this enables a lot of powerful features, this concept might be confusing for developers who have been programming in more static languages, such as Java or C#. This card should help understanding t...
When the iPad won't play an MP4 video
I had trouble serving an MP4 video to my iPad. Although the video complied with all the specs (H.264 codec, up to 1080p, 30 FPS) I always got this error:
This video could not be loaded, either because the server or network failed or because the...
"Require group" doesn't work with Ubuntu's default Apache installation
If you want to use Require group $GROUPNAME
on your default Apache installation like this:
<Directory "/var/www/foobar">
Order allow,deny
Allow from all
Options None
AllowOverride all
AuthName "Area 5...
Fixing Webrat after following an external link
When a Cucumber feature leaves your page through an external Link, Webrat has problems like "Could not find field: "E-mail" (Webrat::NotFoundError)
" using your page afterwards. It will also have trouble following redirects.
Fix it with this ste...
Capybara 0.3.9 Bug: Chaining .find to scope doesn't work
The following code doesn't work like expected:
page.find(css_selector).find(other_css_selector)
The second .find will search the whole dom instead of a scope.
Rumor has it this is fixed in Capybara 0.4.1.
Ruby: Following redirects with the http gem ("httprb")
When making requests using the http
gem you might want to automatically follow redirects to get the desired response. This is supported but not the default behavior.
You can do so by using the .follow
method.
This follows redirects for the f...