Skip to content
Browse files

Use stubbing instead of sleep() in File store cache tests

  • Loading branch information...
1 parent b5775c2 commit 66eb05821b1cb522f497c874e7708fe705fb8356 @lifo lifo committed Jun 21, 2009
Showing with 9 additions and 3 deletions.
  1. +9 −3 activesupport/test/caching_test.rb
View
12 activesupport/test/caching_test.rb
@@ -148,12 +148,18 @@ def teardown
include CacheStoreBehavior
def test_expires_in
+ time = Time.local(2008, 4, 24)
+ Time.stubs(:now).returns(time)
+ File.stubs(:mtime).returns(time)
+
@cache.write('foo', 'bar')
- cache_read = lambda { @cache.read('foo', :expires_in => 2) }
+ cache_read = lambda { @cache.read('foo', :expires_in => 1.minute) }
assert_equal 'bar', cache_read.call
- sleep(1)
+
+ Time.stubs(:now).returns(time + 30.seconds)
assert_equal 'bar', cache_read.call
- sleep(1)
+
+ Time.stubs(:now).returns(time + 2.minutes)
assert_nil cache_read.call
end
end

0 comments on commit 66eb058

Please sign in to comment.
Something went wrong with that request. Please try again.