[cucumber] How to add a after failure hook?


#1

Is currently a way to add a upon failure hook? I’d like to make it so
that,
in the event of a failed assertion, Webrat will take the last requested
page
and open it in a browser.
Thanks :slight_smile:

Tim


#2

2009/4/2 Tim H. removed_email_address@domain.invalid

Is currently a way to add a upon failure hook? I’d like to make it so
that, in the event of a failed assertion, Webrat will take the last
requested page and open it in a browser.

http://wiki.github.com/aslakhellesoy/cucumber/hooks

After do |scenario|

currently no simple way to query scenario for status though :frowning:

end

Please open a ticket for this if you really need it.

Aslak


#3

Hi Tim,

I have used a custom formatter, if this is any help

class ExceptionFormatter < Cucumber::Ast::Visitor

def initialize(step_mother, io, options)
super(step_mother)
end

def visit_feature_name(name)
if name =~ /Feature:\s(.*)/i
@name = $1
else
@name = name
end
end

def visit_exception(exception, status)
exception_file = “#{File.dirname(FILE)}/#{@name}.html”
open(exception_file, ‘w’) { |f| f << browser.html }
end
end

Aidy


#4

Aidy,
This is a great work around, being disadvantaged only by having to
specify a
different formatter :slight_smile:

Still, a general purpose way of hooking in to the after feature fail
would
be premium. Thanks for opening the ticket.

Tim


#5

aslak hellesoy wrote:

|After do |scenario|

currently no simple way to query scenario for status though :frowning:

end
|
Please open a ticket for this if you really need it.

Aslak

Convo has been moved to LH:

https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/272-pick-up-failure-on-after-hook#ticket-272-2

-Ben