Make cucumber open the browser with the current page

The Cucumber Book
describes a really nifty trick when testing web-pages: open the browser
when a step fails. This is a feature provided by cucumber itself.

Add a support file features/support/debugging.rb:

Afterdo|scenario|save_and_open_pageifscenario.failed?end

And add launchy to your gemfile, and bundle install. (or install it with whatever else
you use).

group:testdo#...gem"launchy","~> 2.1.2"end

This will save the page that cucumber is looking at, then open it in
your browser. Works fine, untill you have a large suite of features and
some refactoring breaks many features. Having to close twenty tabs in
your browser after each run is counterproductive and often really
frustrating.

I solved this with a flag that allows me to fire this debugging-trick
only when I need it.
When I have a failing scenario, and I want to investigate it by
inspecting the page, I run my cucumber with an additional
environment-variable:

About the author: Bèr Kessels is an experienced webdeveloper with a great passion for
technology and Open Source. A golden combination to implement that technology in a good and efficient
way. Follow @berkes on Twitter. Or read more about Bèr.