sane Sinatra stack traces in Cucumber
I’m building an app in Sinatra and testing it (in part) with Cucumber. When exceptions were raised in my application, I’d get a stack trace wrapped in pages and pages of HTML - very nice when you’re testing in a browser, but almost impossible to work with in a command-line test. After a surprisingly long investigation, I added these lines to env.rb:
# Don't generate fancy HTML for stack traces. disable :show_exceptions # Allow errors to get out of the app so Cucumber can display them. enable :raise_errors
Both are required. If you just disable :show_exceptions, you’re spared the fancy HTML, but you’re also spared any useful information about what’s going wrong. (You just get “Internal Server Error”.) But if you just enable :raise_errors, well, the errors don’t get raised - they’re trapped by the exception-showing code.