From 53d233c5e619e15a7e4fe41de75f7e8afb0cfca6 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Wed, 12 Jun 2013 15:05:51 -0800 Subject: [PATCH] - Make Spec::DSL.describe_stack thread local to avoid failing on my own tests. - Make a fake Time.now local to the tests so they won't interfere with real reporter timings. [git-p4: depot-paths = "//src/minitest/dev/": change = 8677] --- lib/minitest/spec.rb | 3 +-- test/minitest/test_minitest_mock.rb | 30 +++++++++++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/minitest/spec.rb b/lib/minitest/spec.rb index 2ec5bde3..c7366011 100644 --- a/lib/minitest/spec.rb +++ b/lib/minitest/spec.rb @@ -143,9 +143,8 @@ def spec_type desc }.last end - @@describe_stack = [] def describe_stack # :nodoc: - @@describe_stack + Thread.current[:describe_stack] ||= [] end ## diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb index 202a47aa..98717bfd 100644 --- a/test/minitest/test_minitest_mock.rb +++ b/test/minitest/test_minitest_mock.rb @@ -286,18 +286,22 @@ def teardown assert_equal @assertion_count, @tc.assertions end + class Time + def self.now + 24 + end + end + def assert_stub val_or_callable @assertion_count += 1 - Minitest::Test.synchronize do - t = Time.now.to_i - - Time.stub :now, val_or_callable do - @tc.assert_equal 42, Time.now - end + t = Time.now.to_i - @tc.assert_operator Time.now.to_i, :>=, t + 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_private_module_method @@ -345,15 +349,13 @@ def test_stub_block def test_stub_block_args @assertion_count += 1 - Minitest::Test.synchronize do - t = Time.now.to_i - - Time.stub :now, lambda { |n| n * 2 } do - @tc.assert_equal 42, Time.now(21) - end + t = Time.now.to_i - @tc.assert_operator Time.now.to_i, :>=, t + 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