Permalink
Browse files

Remove everything speccy from test_minitest_unit.rb.

[git-p4: depot-paths = "//src/minitest/dev/": change = 8130]
  • Loading branch information...
1 parent 8210c01 commit 9214d48c23079d817f8b3b4aac781f75ecf406a8 @zenspider zenspider committed Jan 18, 2013
Showing with 50 additions and 23 deletions.
  1. +46 −1 test/minitest/test_minitest_spec.rb
  2. +4 −22 test/minitest/test_minitest_unit.rb
@@ -28,7 +28,7 @@ def assert_triggered expected = "blah", klass = MiniTest::Assertion
end
after do
- self._assertions.must_equal @assertion_count
+ self._assertions.must_equal @assertion_count if passed? and not skipped?
end
it "needs to be able to catch a MiniTest::Assertion exception" do
@@ -729,3 +729,48 @@ def with_output # REFACTOR: dupe from metametameta
end
end
end
+
+require "minitest/metametameta"
+
+class TestSpecInTestCase < MetaMetaMetaTestCase
+ def setup
+ super
+
+ @tc = MiniTest::Unit::TestCase.new 'fake tc'
+ @assertion_count = 1
+ end
+
+ def util_assert_triggered expected, klass = MiniTest::Assertion # REFACTOR
+ e = assert_raises klass do
+ yield
+ end
+
+ msg = e.message.sub(/(---Backtrace---).*/m, '\1')
+ msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
+
+ assert_equal expected, msg
+ end
+
+ def teardown # REFACTOR
+ assert_equal(@assertion_count, @tc._assertions,
+ "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc.passed?
+ end
+
+ def test_expectation
+ @assertion_count = 2
+
+ @tc.assert_equal true, 1.must_equal(1)
+ end
+
+ def test_expectation_triggered
+ util_assert_triggered "Expected: 2\n Actual: 1" do
+ 1.must_equal 2
+ end
+ end
+
+ def test_expectation_with_a_message
+ util_assert_triggered "Expected: 2\n Actual: 1" do
+ 1.must_equal 2, ''
+ end
+ end
+end
@@ -644,12 +644,12 @@ def test_omg; assert true; end
def test_setup_and_teardown_survive_inheritance
call_order = []
- parent = Class.new MiniTest::Spec do
- before do
+ parent = Class.new MiniTest::Unit::TestCase do
+ define_method :setup do
call_order << :setup_method
end
- after do
+ define_method :teardown do
call_order << :teardown_method
end
@@ -690,7 +690,7 @@ def setup
def teardown
assert_equal(@assertion_count, @tc._assertions,
- "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc._assertions
+ "expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc.passed?
end
def non_verbose
@@ -1381,24 +1381,6 @@ def test_class_asserts_match_refutes
assert_empty asserts.map { |n| n.sub(/^assert/, 'refute') } - refutes
end
- def test_expectation
- @assertion_count = 2
-
- @tc.assert_equal true, 1.must_equal(1)
- end
-
- def test_expectation_triggered
- util_assert_triggered "Expected: 2\n Actual: 1" do
- 1.must_equal 2
- end
- end
-
- def test_expectation_with_a_message
- util_assert_triggered "Expected: 2\n Actual: 1" do
- 1.must_equal 2, ''
- end
- end
-
def test_flunk
util_assert_triggered 'Epic Fail!' do
@tc.flunk

0 comments on commit 9214d48

Please sign in to comment.