From: Bret Pettichord Date: 2005-10-08T00:37:33+09:00 Subject: Re: Enhancing/overriding Test::Unit::Assertion methods--what's the best way? At 08:16 PM 10/6/2005, joe.yakich@gmail.com wrote: >I have a little screen capture routine that I'd like to use >automatically if possible when I use any of the Test::Unit assert >flavors, such as assert, assert_equals, assert_match, etc. (whether or >not the assertion returns true or false). > >Is there a spiffy way to override or enhance/extend Test::Unit to do >that? (I'm new to Ruby, and haven't grasped what it means to extend it; >I see in the PickAxe book there's mention of using C, but I think >there's another way to accomplish what I'm describing.) Assertions is a module that is included in (mixed in) TestCase. You should create a new mixin. module AssertWithScreenCapture def assert(*args) capture_screen Test::Unit::Assertions::assert(*args) end end Then use "include AssertWithScreenCapture" in the test cases you want the 'overridded' behavior. _____________________ Bret Pettichord www.pettichord.com