Forum: RSpec [cucumber] How to add a after failure hook?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
63f259ca39670e260cd50dd71013663c?d=identicon&s=25 Tim Harper (timcharper)
on 2009-04-02 01:12
(Received via mailing list)
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 :)

Tim
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-04-02 01:53
(Received via mailing list)
2009/4/2 Tim Harper <timcharper@gmail.com>

> 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 :-(
end

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

Aslak
Ee6788c2faaad7a5cd0bc466c9ea60d8?d=identicon&s=25 aidy lewis (Guest)
on 2009-04-02 18:40
(Received via mailing list)
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
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2009-04-02 20:19
(Received via mailing list)
aslak hellesoy wrote:
> |After do |scenario|
>   # currently no simple way to query scenario for status though :-(
> 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-cuc...

-Ben
63f259ca39670e260cd50dd71013663c?d=identicon&s=25 Tim Harper (timcharper)
on 2009-04-02 23:36
(Received via mailing list)
Aidy,
This is a great work around, being disadvantaged only by having to
specify a
different formatter :)

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

Tim
This topic is locked and can not be replied to.