mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Imported minitest 3.0.0 (r7435) w/ fixes for rubygems. 10955 tests, 2253343 assertions, 1 failures, 1 errors, 28 skips minus drb tests on x86_64-darwin11.3.0 and reviewed by drbrain
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2dece928e0
commit
a213c2ed9c
9 changed files with 184 additions and 67 deletions
|
@ -210,3 +210,62 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
|
|||
assert_equal exp, e.message
|
||||
end
|
||||
end
|
||||
|
||||
require "test/minitest/metametameta"
|
||||
|
||||
class TestMiniTestStub < MiniTest::Unit::TestCase
|
||||
def setup
|
||||
super
|
||||
MiniTest::Unit::TestCase.reset
|
||||
|
||||
@tc = MiniTest::Unit::TestCase.new 'fake tc'
|
||||
@assertion_count = 1
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
assert_equal @assertion_count, @tc._assertions
|
||||
end
|
||||
|
||||
def assert_stub val_or_callable
|
||||
@assertion_count += 1
|
||||
|
||||
t = Time.now.to_i
|
||||
|
||||
Time.stub :now, val_or_callable do
|
||||
@tc.assert_equal 42, Time.now
|
||||
end
|
||||
|
||||
@tc.assert_operator Time.now.to_i, :>=, t
|
||||
end
|
||||
|
||||
def test_stub_value
|
||||
assert_stub 42
|
||||
end
|
||||
|
||||
def test_stub_block
|
||||
assert_stub lambda { 42 }
|
||||
end
|
||||
|
||||
def test_stub_block_args
|
||||
@assertion_count += 1
|
||||
|
||||
t = Time.now.to_i
|
||||
|
||||
Time.stub :now, lambda { |n| n * 2 } do
|
||||
@tc.assert_equal 42, Time.now(21)
|
||||
end
|
||||
|
||||
@tc.assert_operator Time.now.to_i, :>=, t
|
||||
end
|
||||
|
||||
def test_stub_callable
|
||||
obj = Object.new
|
||||
|
||||
def obj.call
|
||||
42
|
||||
end
|
||||
|
||||
assert_stub obj
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue