summaryrefslogtreecommitdiff
path: root/test/minitest/test_mini_test.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-25 22:38:09 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-10-25 22:38:09 +0000
commit17358af75b80343f7861907b9288607e67a08f61 (patch)
tree42e57053dce062666184382e21ea763c0e1101ea /test/minitest/test_mini_test.rb
parentfe7ce06150e75f524f2aaaf3198927a58873d9a1 (diff)
Imported minitest 1.3.0 r4429. Fixes issues reported by akira and nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/minitest/test_mini_test.rb')
-rw-r--r--test/minitest/test_mini_test.rb54
1 files changed, 40 insertions, 14 deletions
diff --git a/test/minitest/test_mini_test.rb b/test/minitest/test_mini_test.rb
index f5a48cb535..8561acb5bf 100644
--- a/test/minitest/test_mini_test.rb
+++ b/test/minitest/test_mini_test.rb
@@ -9,8 +9,10 @@ require 'minitest/unit'
MiniTest::Unit.autorun
-class TestMiniTest < MiniTest::Unit::TestCase
+module M; end
+class E < StandardError; include M; end
+class TestMiniTest < MiniTest::Unit::TestCase
def setup
srand 42
MiniTest::Unit::TestCase.reset
@@ -248,10 +250,10 @@ Finished in 0.00
"
output = @output.string.sub(/Finished in .*/, "Finished in 0.00")
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
- output.sub!(/[\w\/\.]+:\d+/, 'FILE:LINE')
+ output.sub!(/^(\s+)(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+:/o, '\1FILE:LINE:')
+ output.sub!(/\[(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+\]/o, '[FILE:LINE]')
assert_equal(expected, output)
- end
-
+ end
def test_run_failing_filtered
tc = Class.new(MiniTest::Unit::TestCase) do
def test_something
@@ -426,7 +428,7 @@ class TestMiniTestTestCase < MiniTest::Unit::TestCase
end
def test_assert_includes_triggered
- @assertion_count = 4
+ @assertion_count = 3
e = @tc.assert_raises MiniTest::Assertion do
@tc.assert_includes [true], false
@@ -489,31 +491,35 @@ class TestMiniTestTestCase < MiniTest::Unit::TestCase
end
def test_assert_raises
- @assertion_count = 2
-
@tc.assert_raises RuntimeError do
raise "blah"
end
end
- def test_assert_raises_triggered_different
- @assertion_count = 2
+ def test_assert_raises_module
+ @tc.assert_raises M do
+ raise E
+ end
+ end
+ def test_assert_raises_triggered_different
e = assert_raises MiniTest::Assertion do
@tc.assert_raises RuntimeError do
raise SyntaxError, "icky"
end
end
- expected = "<[RuntimeError]> exception expected, not
+ expected = "[RuntimeError] exception expected, not
Class: <SyntaxError>
Message: <\"icky\">
---Backtrace---
FILE:LINE:in `test_assert_raises_triggered_different'
----------------.
-Expected [RuntimeError] to include SyntaxError."
+---------------"
- assert_equal expected, expected.gsub(/[\w\/\.]+:\d+/, 'FILE:LINE')
+ actual = e.message.gsub(/[\w\/\.]+:\d+/, 'FILE:LINE')
+ actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/
+
+ assert_equal expected, actual
end
def test_assert_raises_triggered_none
@@ -528,6 +534,26 @@ Expected [RuntimeError] to include SyntaxError."
assert_equal expected, e.message
end
+ def test_assert_raises_triggered_subclass
+ e = assert_raises MiniTest::Assertion do
+ @tc.assert_raises StandardError do
+ raise E
+ end
+ end
+
+ expected = "[StandardError] exception expected, not
+Class: <E>
+Message: <\"E\">
+---Backtrace---
+FILE:LINE:in `test_assert_raises_triggered_subclass'
+---------------"
+
+ actual = e.message.gsub(/[\w\/\.]+:\d+/, 'FILE:LINE')
+ actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/
+
+ assert_equal expected, actual
+ end
+
def test_assert_respond_to
@tc.assert_respond_to "blah", :empty?
end
@@ -733,7 +759,7 @@ Expected [RuntimeError] to include SyntaxError."
end
def test_refute_includes_triggered
- @assertion_count = 4
+ @assertion_count = 3
e = @tc.assert_raises MiniTest::Assertion do
@tc.refute_includes [true], true