title: capybara-webkit: automatically save a screenshot on an RSpec test failure
body: <p>How can I automatically save the html and a screenshot when a test fails using capybara-webkit with Rspec? How can I execute a callback when an RSpec test fails.</p>
  
  <p>Bonus points: how can I avoid getting the following error:</p>
  
  <pre><code>Capybara::Driver::Webkit::WebkitInvalidResponseError 
  </code></pre>
  
  <p>when executing this code:</p>
  
  <pre><code>require 'capybara/util/save_and_open_page'
  path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
  png = Capybara.save_and_open_page_path + "#{path}.png"
  page.driver.render Rails.root.join(png)
  </code></pre>