Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
exceptions are displayed in the console when integration testing with capybara
# Given an application, yield to a block to handle exceptions
class ExceptionRaiserApp
def initialize(app, &block)
@app = app
@block = block
def call(env)
rescue => e
# Wrap ShortmailApp with the exception raiser = do |exception|
# Write to standard error
$stderr.write [
# The name of the exception and its message
exception.to_s + ": "+ exception.message,
# And a nice clean rails backtrace
Rails.backtrace_cleaner.clean(exception.backtrace, :silent),
# Then re-raise so capybara gets a 500 and knows what's up
raise exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment