Bug #9660
closed
I guess this ugly patch fixes problem, but I want to find better solutions...
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index ccfe1ce..eb7545b 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -1,5 +1,25 @@
-gem 'minitest', '< 5.0.0' if defined? Gem
+if defined? Gem
+ begin
+ gem 'minitest', '< 5.0.0'
+ rescue Gem::LoadError # for bundler
+ end
+end
+
require 'minitest/unit'
+
+if '5.0.0' <= MiniTest::Unit::VERSION
+ module Test
+ module Unit
+ class CompatibilityError < Exception
+ end
+ end
+ end
+
+ raise Test::Unit::CompatibilityError,
+ "test/unit only works on MiniTest 4 " \
+ "(MiniTest #{MiniTest::Unit::VERSION} loaded)"
+end
+
require 'test/unit/assertions'
require 'test/unit/testcase'
require 'optparse'
I think bundled test-unit should be rename like rbunit or ruby-unit. many of users is confused by bundled test-unit and test-unit gem.
If we can't merge their, it should be renamed.
I like the name ruby-unit, in this case we should also consider changing the namespaces to match (ie: RubyUnit)
e@zzak.io wrote:
I like the name ruby-unit, in this case we should also consider
changing the namespaces to match (ie: RubyUnit)
Might as well use Minitest:: at that point, right?
normalperson@yhbt.net wrote:
e@zzak.io wrote:
I like the name ruby-unit, in this case we should also consider
changing the namespaces to match (ie: RubyUnit)
Might as well use Minitest:: at that point, right?
Nevermind, there's a lot of old assertions which Minitest drops.
Maybe we can do it long term.
Hello,
I take the liberty to link to a branch with a beginning of patch that updates the bundled version of Minitest to 5 (https://github.com/robin850/ruby/compare/minitest-five) since this is more or less related to the problem here. IMO, this is really bad to have a "deprecated"/out dated version of a library that you're shipping with by default. I'm conscious that the amount of work would be pretty important to rename all Test::Unit::TestCase
classes to Minitest::Test
but the wrapper is not so nice.
Moreover, I don't think the amount of work needed to rename the test suite is really worth regarding the final result. The test cases would have to be renamed anyway if we follow Zachary's suggestion (which is legit, I think ; it would make no sense to have a ruby/unit.rb file with a Test::Unit
class in it).
I find it sometimes annoying to have to create a Gemfile adding gem 'minitest'
in it just to use an up to date version of Minitest.
I'm pretty sure you have good reasons to stuck with Test::Unit inside your test suite, but just my two cents here.
Have a nice day.
- Related to Feature #9711: Remove test-unit and minitest from stdlib. added
- Status changed from Open to Closed
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0