mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Use stubbing instead of sleep() in File store cache tests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user