Skip to content

Instantly share code, notes, and snippets.

@akostadinov
Last active April 14, 2022 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akostadinov/2889fb1d7b79fbbcb119 to your computer and use it in GitHub Desktop.
Save akostadinov/2889fb1d7b79fbbcb119 to your computer and use it in GitHub Desktop.
hack cucumber 1.3 to have an entry point to debug and 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