Skip to content

Instantly share code, notes, and snippets.

@puyo
Created January 31, 2014 04:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puyo/8726739 to your computer and use it in GitHub Desktop.
Save puyo/8726739 to your computer and use it in GitHub Desktop.
More useful output from Capybara
# More useful output from Capybara.
#
# Before:
#
# Unable to find link or button "Year 5"
#
# After:
#
# Unable to find link or button "Year 5" in "Sorry, something went wrong We've
# been notified of the error and are looking into it."
#
# Installation:
#
# Copy to `spec/support/capybara_find_with_info.rb`
#
require 'capybara/node/finders'
module Capybara
module Node
module Finders
def find_with_info(*args)
begin
find_without_info(*args)
rescue Capybara::ElementNotFound => e
raise e.class, "#{e.message} in \"#{text}\"", e.backtrace
end
end
alias_method_chain :find, :info
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment