When searching for test failure, accept either MiniTest::Assertion or Test::Unit::AssertionFailedError for Ruby 1.9 compatibility.

This commit is contained in:
Dean Strelau 2009-06-02 22:41:17 -04:00
parent f062a6924e
commit 13ff067422
1 changed files with 6 additions and 1 deletions

View File

@ -13,7 +13,12 @@ module Shoulda
# end
def should_fail(&block)
context "should fail when trying to run:" do
Shoulda.expected_exceptions = [Test::Unit::AssertionFailedError]
if defined?(Test::Unit::AssertionFailedError)
failures = [Test::Unit::AssertionFailedError]
elsif defined?(MiniTest::Assertion)
failures = [MiniTest::Assertion]
end
Shoulda.expected_exceptions = failures
yield block
Shoulda.expected_exceptions = nil
end