Skip to content

Commit

Permalink
Sharpen stub tests. (ab9)
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/minitest/dev/": change = 8463]
  • Loading branch information
zenspider committed Apr 25, 2013
1 parent 2e06cd4 commit c7c620b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/minitest/test_minitest_mock.rb
Expand Up @@ -315,22 +315,22 @@ def test_stub_private_module_method
def test_stub_private_module_method_indirect
@assertion_count += 1

slow_clapper = Class.new do
def slow_clap
sleep 3
fail_clapper = Class.new do
def fail_clap
fail
:clap
end
end.new

slow_clapper.stub :sleep, nil do |fast_clapper|
@tc.assert_equal :clap, fast_clapper.slow_clap # either form works
@tc.assert_equal :clap, slow_clapper.slow_clap # yay closures
fail_clapper.stub :fail, nil do |safe_clapper|
@tc.assert_equal :clap, safe_clapper.fail_clap # either form works
@tc.assert_equal :clap, fail_clapper.fail_clap # yay closures
end
end

def test_stub_public_module_method
Math.stub(:log10, 42.0) do
@tc.assert_in_delta 42.0, Math.log10(1000)
Math.stub :log10, :stubbed do
@tc.assert_equal :stubbed, Math.log10(1000)
end
end

Expand Down

0 comments on commit c7c620b

Please sign in to comment.