Do you find yourself using the save_and_open_page method to debug your cucumber features? Or how about raising exceptions to break the scenario execution? I guess it works, but not very elegant…
One easy way to pause the scenario execution after each step is to use the cucumber callbacks.
Start by creating a hooks.rb file in your features/support folder. You can name the file whatever you want, but it must have a .rb extension. Then add the following snippet to your new file:
AfterStep('@pause') do print "Press Return to continue..." STDIN.getc end
What we’re doing here is using the AfterStep callback to execute our code after each cucumber steps has finished. The parameter is telling cucumber to only do this for features that have the @pause tag. We then wait for a carriage return from the console before moving to the next step.
Now all you have to do is tag a feature with @pause and you will have to press Return after each step to walk through the scenario. This makes debugging a snap when you’re using something like Firebug etc.
Try it out for yourself.