Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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