Skip to content

Instantly share code, notes, and snippets.

@steveklabnik
Last active December 16, 2015 08:39
Embed
What would you like to do?
Why does this print something?
require 'minitest/autorun'
module Kernel
def sleep(n)
puts "calling sleep"
end
end
describe "stub" do
it "stubs stuff" do
Kernel.stub(:sleep, nil) do
sleep(5)
end
end
end
$ ruby bug.rb
Run options: --seed 13072
# Running tests:
calling sleep
.
Finished tests in 0.001058s, 945.1796 tests/s, 0.0000 assertions/s.
1 tests, 0 assertions, 0 failures, 0 errors, 0 skips
steve at thoth-2 in ~/tmp
$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
steve at thoth-2 in ~/tmp
$ gem list minitest
*** LOCAL GEMS ***
minitest (4.7.0, 4.6.2, 4.6.1, 4.6.0, 4.3.3, 4.3.2)
minitest-rails (0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment