Last active
April 14, 2022 11:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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