From: David Gamba Date: 2012-12-20T00:16:40+09:00 Subject: Re: Test::Unit : assert_aborts I just found this thread and could only run the code with ruby 1.9.3 but my server has 1.8.7 so I needed to tweak it a bit: require 'test/unit' require "stringio" class TestA < Test::Unit::TestCase def assert_aborts(message) e = assert_raises SystemExit do previous_stderr = $stderr $stderr = StringIO.new yield end assert_equal message, e.message ensure $stderr = previous_stderr end def test_a assert_aborts "hi" do abort "hi" end end end Also one can change the assert_equal for an assert_match to use a regex. Thanks :) -- View this message in context: http://ruby.11.n6.nabble.com/Test-Unit-assert-aborts-tp3396686p4985455.html Sent from the ruby-talk mailing list archive at Nabble.com.