以下代码(没有 Gemfile)适用于 Ruby 2.1.1,但不适用于 Ruby 2.2.0
require "bundler/setup"
gem "minitest", "4.7.5"
require "test/unit"
class TestFoo < Test::Unit::TestCase
def test_foo
assert true, "Useless mesage"
skip "Skip works"
end
end
在 Ruby 2.1.1 上,我得到
Run options:
# Running tests:
[1/1] TestFoo#test_foo = 0.00 s
1) Skipped:
TestFoo#test_foo [test_220.rb:8]:
Skip works
Finished tests in 0.004435s, 225.4791 tests/s, 225.4791 assertions/s.
1 tests, 1 assertions, 0 failures, 0 errors, 1 skips
ruby -v: ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin10.0]
但是在 Ruby 2.2.0 上,我得到了
192-168-1-5:test_220 agrimm$ ruby test_220.rb
Loaded suite test_220
Started
E
===============================================================================
Error: test_foo(TestFoo)
: NoMethodError: undefined method `skip' for #<TestFoo:0x007fb75484f158>
test_220.rb:8:in `test_foo'
5: class TestFoo < Test::Unit::TestCase
6: def test_foo
7: assert true, "Useless mesage"
=> 8: skip "Skip works"
9: end
10: end
===============================================================================
Finished in 0.001504 seconds.
1 tests, 1 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
664.89 tests/s, 664.89 assertions/s
$ ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13]
我怀疑这是因为与 Ruby 2.2.0 相关的更改:
更新 test-unit 3.0.8(从存储库中删除但捆绑在 tarball 中)
更新 minitest 5.4.3(从存储库中删除但捆绑在 tarball 中)
如何使代码在 Ruby 2.2 上运行,最好是用最少的代码更改?