You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
andrewblack edited this page Jan 8, 2012
·
3 revisions
Chris and I (Andrew Black) were discussing how to get a cucumber test to stop and get into debug (or irb).
I have come up with two different ways by googling. It would be nice to choose the better one (or combine them) and get this into the app.
How to call
Place a step called cucumber
Add a tag @stop to the step you want to debug
Add a call to debugger in the ruby code you want to
What to do when you stop
call rdb (ruby debugger)
call irb (interactive ruby)
call pry ( suggestion by Chris Adams - not tried yet)
How implemented
Detailed code
step_definitions/debug_steps.rb
When "debugger" do
debugger
end
support/stop.rb
# Usage:
# @wip @stop
# Scenario: change password
# ........................
# $ cucumber -p wip
# Comes from :
# http://railsdog.com/blog/2011/02/22/cucumber-testing-tips/
#
# orinal jhad
# ... scenario.failed? && scenario.source_tag_names.include?("@wip") &&
After do |scenario|
if scenario.source_tag_names.include?("@stop")
puts "Scenario failed. You are in rails console becuase of @stop. Type exit when you are done"
require 'irb'
require 'irb/completion'
ARGV.clear
IRB.start
end
end