formula_assertions: make removable on Ruby 2.0.

This commit is contained in:
Mike McQuaid 2017-07-07 09:43:39 +01:00 committed by GitHub
parent 5b464babf8
commit 7aaa7e1b79

View File

@ -3,17 +3,9 @@ module Homebrew
require "test/unit/assertions" require "test/unit/assertions"
include ::Test::Unit::Assertions include ::Test::Unit::Assertions
# Custom name here for cross-version compatibility. # TODO: remove this when we no longer support Ruby 2.0.
# In Ruby 2.0, Test::Unit::Assertions raise a MiniTest::Assertion, unless defined?(Test::Unit::AssertionFailedError)
# but they raise Test::Unit::AssertionFailedError in 2.3. Test::Unit::AssertionFailedError = MiniTest::Assertion
# If neither is defined, this might be a completely different
# version of Ruby.
if defined?(MiniTest::Assertion)
AssertionFailed = MiniTest::Assertion
elsif defined?(Test::Unit::AssertionFailedError)
AssertionFailed = Test::Unit::AssertionFailedError
else
raise NameError, "Unable to find an assertion class for this version of Ruby (#{RUBY_VERSION})"
end end
# Returns the output of running cmd, and asserts the exit status # Returns the output of running cmd, and asserts the exit status