summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-19 20:34:21 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-19 20:34:21 +0000
commit9bec8ef50ce1858ee2070a1637447eb12ce89990 (patch)
treee6cece58a34cf857c56e47bab13a5eeacd71af71 /test
parent9cfc7a658f1e6f97fd88ee69310f4ccc5f20d73c (diff)
Imported minitest 2.6.2 (r6712)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/minitest/test_minitest_mock.rb1
-rw-r--r--test/minitest/test_minitest_spec.rb25
-rw-r--r--test/minitest/test_minitest_unit.rb22
3 files changed, 39 insertions, 9 deletions
diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb
index b6e801c3aa..8ba29840d4 100644
--- a/test/minitest/test_minitest_mock.rb
+++ b/test/minitest/test_minitest_mock.rb
@@ -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
diff --git a/test/minitest/test_minitest_spec.rb b/test/minitest/test_minitest_spec.rb
index d9f6368a80..27e3dc7628 100644
--- a/test/minitest/test_minitest_spec.rb
+++ b/test/minitest/test_minitest_spec.rb
@@ -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
diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb
index c921ca749e..39e44a33d8 100644
--- a/test/minitest/test_minitest_unit.rb
+++ b/test/minitest/test_minitest_unit.rb
@@ -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