On Wed, Dec 19, 2012 at 12:15 PM, Željko Filipin
<[email protected]>wrote:

> That said, I have simplified the code that you have posted a bit, and it
> rescues the exception on my machine.
>
> require 'test/unit'
> class TC_Sample < Test::Unit::TestCase
>   def test_01
>      begin
>       assert(false)
>     rescue Test::Unit::AssertionFailedError
>       puts "Batdog to the Rescue!"
>      end
>   end
> end
>

Simplifying the code even further (methods do not need begin-end block to
use rescue) and adding a piece of Justin's wisdom:

require 'test/unit'
class TC_Sample < Test::Unit::TestCase
  def test_01
    assert(false)
  rescue MiniTest::Assertion
    p "Batdog to the Rescue!"
  end
end

$ ruby test.rb
Run options:
# Running tests:
"Batdog to the Rescue!"
.
Finished tests in 0.001786s, 559.9104 tests/s, 559.9104 assertions/s.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips

Can you notice an interesting bug in the output? :)

Željko

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to