Skip to content

Instantly share code, notes, and snippets.

@jrafanie
Created September 8, 2011 15:50
Show Gist options
  • Save jrafanie/1203731 to your computer and use it in GitHub Desktop.
Save jrafanie/1203731 to your computer and use it in GitHub Desktop.
Debug cucumber failures using akephalos console
Enhanced the idea found here:
http://railsdog.com/blog/2011/02/22/cucumber-testing-tips/
# Stop a feature/scenario at the point of a failure and drop into an rails console
# with access to the current page via akephalos with the application
# running, pre-transaction rollback, accessible in a browser on localhost:9887
#
# Usage:
# @wip @stop
# Scenario: change password
# ........................
# When I go to "the page I want to debug"
# Then I should see "some string that will not exist and cause the scenario to fail"
# ........................
#
# $ cucumber -p wip
#
# Additionally, provides access to the akephalos page to enable page debugging:
# >> page.find_link("Delete")
After do |scenario|
if scenario.failed? && scenario.source_tag_names.include?("@wip") && scenario.source_tag_names.include?("@stop")
puts "Scenario failed. You are in rails console because of @stop. Type exit when you are done"
require 'irb'
require 'irb/completion'
ARGV.clear
require 'rubygems'
require 'akephalos'
require 'akephalos/console'
IRB.start
end
end
Enhanced the idea found here:
http://railsdog.com/blog/2011/02/22/cucumber-testing-tips/
Drop this into your hooks.rb. A similar idea can be done with rspec.
# Stop a feature/scenario at the point of a failure and drop into an rails console
# with access to the current page via akephalos with the application
# running, pre-transaction rollback, accessible in a browser on localhost:9887
#
# Usage:
# @wip @stop
# Scenario: change password
# ........................
# When I go to "the page I want to debug"
# Then I should see "some string that will not exist and cause the scenario to fail"
# ........................
#
# $ cucumber -p wip
#
# Additionally, provides access to the akephalos page to enable page debugging:
# >> page.find_link("Delete")
After do |scenario|
if scenario.failed? && scenario.source_tag_names.include?("@wip") && scenario.source_tag_names.include?("@stop")
puts "Scenario failed. You are in rails console because of @stop. Type exit when you are done"
require 'irb'
require 'irb/completion'
ARGV.clear
require 'rubygems'
require 'akephalos'
require 'akephalos/console'
IRB.start
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment