Skip to content


Printing the page content in Capybara

Capybara is a great integration testing framework that easily replaces Webrat. Plus, it works with Rails 3, which Webrat seems not to do.

If you need to print the current page’s content, for example to debug your test, you can do so with:

    puts page.body

This trick is a bit hard to find in the documentation.

Update: There is also

    save_and_open_page

which opens the page content in a browser.

Posted in Ruby on Rails.