Skip to content

Instantly share code, notes, and snippets.

@akostadinov akostadinov/cucumber_pry
Last active Aug 29, 2015

Embed
What would you like to do?
hack cucumber to have an entry point to debug abd continue scenario after failure
# execute this code to fall into a pry session upoon step failure
# works only with cucumber 1.3
# so far for 2.0 best similar approach is to us the After hook
# fall into pry/buybug if scenario.failed? is true
# After hook works for 1.3 as well
Cucumber::Ast::StepInvocation.class_eval do
## first make sure we don't lose original accept method
unless self.instance_methods.include?(:orig_accept)
alias_method :orig_accept, :accept
end
## wrap original accept method to catch errors in executed step
def accept(visitor)
orig_accept(visitor)
if @exception && ! @exception.class.name.start_with?("Cucumber::")
# @exception = nil # to continue with following steps
# cd visitor.runtime/@support_code
# cd @programming_languages[0].current_world
# binding.pry
# visitor.configuration
require 'pry'
binding.pry
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.