mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
Imported minitest 2.6.2 (r6712)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9cfc7a658f
commit
9bec8ef50c
8 changed files with 119 additions and 24 deletions
|
@ -91,6 +91,7 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
|
|||
|
||||
def test_respond_appropriately
|
||||
assert @mock.respond_to?(:foo)
|
||||
assert @mock.respond_to?('foo')
|
||||
assert !@mock.respond_to?(:bar)
|
||||
end
|
||||
|
||||
|
|
|
@ -95,11 +95,16 @@ describe MiniTest::Spec do
|
|||
proc { 42.must_be_nil }.must_raise MiniTest::Assertion
|
||||
end
|
||||
|
||||
it "needs to verify using any operator" do
|
||||
it "needs to verify using any binary operator" do
|
||||
41.must_be(:<, 42).must_equal true
|
||||
proc { 42.must_be(:<, 41) }.must_raise MiniTest::Assertion
|
||||
end
|
||||
|
||||
it "needs to verify using any predicate" do
|
||||
"".must_be(:empty?).must_equal true
|
||||
proc { "blah".must_be(:empty?) }.must_raise MiniTest::Assertion
|
||||
end
|
||||
|
||||
it "needs to catch an expected exception" do
|
||||
@assertion_count = 2
|
||||
|
||||
|
@ -156,6 +161,11 @@ describe MiniTest::Spec do
|
|||
proc { "blah".wont_match(/\w+/) }.must_raise MiniTest::Assertion
|
||||
end
|
||||
|
||||
it "needs to verify using any (negative) predicate" do
|
||||
"blah".wont_be(:empty?).must_equal false
|
||||
proc { "".wont_be(:empty?) }.must_raise MiniTest::Assertion
|
||||
end
|
||||
|
||||
it "needs to verify non-nil" do
|
||||
42.wont_be_nil.must_equal false
|
||||
proc { nil.wont_be_nil }.must_raise MiniTest::Assertion
|
||||
|
@ -277,6 +287,9 @@ class TestMeta < MiniTest::Unit::TestCase
|
|||
before { before_list << 3 }
|
||||
after { after_list << 3 }
|
||||
it "inner-it" do end
|
||||
|
||||
it {} # ignore me
|
||||
specify {} # anonymous it
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -328,11 +341,13 @@ class TestMeta < MiniTest::Unit::TestCase
|
|||
assert_equal "very inner thingy", z.desc
|
||||
|
||||
top_methods = %w(test_0001_top_level_it)
|
||||
inner_methods = %w(test_0001_inner_it)
|
||||
inner_methods1 = %w(test_0001_inner_it)
|
||||
inner_methods2 = inner_methods1 +
|
||||
%w(test_0002_anonymous test_0003_anonymous)
|
||||
|
||||
assert_equal top_methods, x.instance_methods(false).sort.map {|o| o.to_s }
|
||||
assert_equal inner_methods, y.instance_methods(false).sort.map {|o| o.to_s }
|
||||
assert_equal inner_methods, z.instance_methods(false).sort.map {|o| o.to_s }
|
||||
assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s)
|
||||
assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s)
|
||||
assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s)
|
||||
end
|
||||
|
||||
def test_setup_teardown_behavior
|
||||
|
|
|
@ -587,7 +587,7 @@ Finished tests in 0.00
|
|||
end
|
||||
|
||||
def util_expand_bt bt
|
||||
if RUBY_VERSION =~ /^1\.9/ then
|
||||
if RUBY_VERSION >= '1.9.0' then
|
||||
bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
|
||||
else
|
||||
bt
|
||||
|
@ -883,6 +883,13 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|||
@tc.assert_operator 2, :>, 1
|
||||
end
|
||||
|
||||
def test_assert_operator_bad_object
|
||||
bad = Object.new
|
||||
def bad.==(other) true end
|
||||
|
||||
@tc.assert_operator bad, :equal?, bad
|
||||
end
|
||||
|
||||
def test_assert_operator_triggered
|
||||
util_assert_triggered "Expected 2 to be < 1." do
|
||||
@tc.assert_operator 2, :<, 1
|
||||
|
@ -990,7 +997,7 @@ FILE:LINE:in `test_assert_raises_triggered_different'
|
|||
---------------"
|
||||
|
||||
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
||||
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/
|
||||
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
@ -1011,7 +1018,7 @@ FILE:LINE:in `test_assert_raises_triggered_different_msg'
|
|||
---------------"
|
||||
|
||||
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
||||
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/
|
||||
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
@ -1055,7 +1062,7 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|||
---------------"
|
||||
|
||||
actual = e.message.gsub(/^.+:\d+/, 'FILE:LINE')
|
||||
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/
|
||||
actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION >= '1.9.0'
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
@ -1364,6 +1371,13 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|||
@tc.refute_operator 2, :<, 1
|
||||
end
|
||||
|
||||
def test_refute_operator_bad_object
|
||||
bad = Object.new
|
||||
def bad.==(other) true end
|
||||
|
||||
@tc.refute_operator true, :equal?, bad
|
||||
end
|
||||
|
||||
def test_refute_operator_triggered
|
||||
util_assert_triggered "Expected 2 to not be > 1." do
|
||||
@tc.refute_operator 2, :>, 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue