Forum: Ruby Adding an Observer to Test::Unit::TestResult

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
cgmjr (Guest)
on 2006-01-03 22:09
(Received via mailing list)
Can anyone share with me on how you would subscribe
to Test::Unit::TestResult with a Observer?  Currently I have working
this, but it seems clumsy to me:
require 'test/unit'
require 'enumerator'

class Report_failure

    def initialize
        tresultinstance=ObjectSpace.enum_for( :each_object,
Test::Unit::TestResult ).to_a

    def notify_failure(failure)
        printf "Observed failure =%s \n", failure.long_display

But in Ed. 1 of Dave, Chad, and Andy's book there's the cool
add_observer bit, as in:

  def initialize(ticker, limit)
    @limit = limit
    ticker.add_observer(self)   # all warners are observers

I need some style hints.  Has add_observer been deprecated in 1.8.2?

Many thanks!
This topic is locked and can not be replied to.