aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-06-21 14:51:43 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-06-21 15:25:28 +0100
commit66eb05821b1cb522f497c874e7708fe705fb8356 (patch)
tree2c709c4c66cfe505d9dcb8f85ca8fea3f99f5bb9
parentb5775c2b3efb3ae5ef9074d26f6fc3e302a4f6f0 (diff)
downloadrails-66eb05821b1cb522f497c874e7708fe705fb8356.tar.gz
rails-66eb05821b1cb522f497c874e7708fe705fb8356.tar.bz2
rails-66eb05821b1cb522f497c874e7708fe705fb8356.zip
Use stubbing instead of sleep() in File store cache tests
-rw-r--r--activesupport/test/caching_test.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index e6e2205708..c2a03818e1 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -148,12 +148,18 @@ class FileStoreTest < ActiveSupport::TestCase
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