test/rack/cache/entitystore/redis_test.rb in redis-rack-cache-2.0.2 vs test/rack/cache/entitystore/redis_test.rb in redis-rack-cache-2.1.0
- old
+ new
@@ -9,17 +9,32 @@
describe Rack::Cache::EntityStore::Redis do
before do
@store = ::Rack::Cache::EntityStore::Redis.new :host => 'localhost'
end
+ it 'respects the default_tll options' do
+ @store = ::Rack::Cache::EntityStore::Redis.new({ :host => 'localhost' }, { :default_ttl => 120 })
+ @store.default_ttl.must_equal(120)
+ end
+
+ it 'properly delegates the TTL to redis' do
+ @store = ::Rack::Cache::EntityStore::Redis.new({ :host => 'localhost' }, { :default_ttl => 120 })
+ key, size = @store.write(['She rode to the devil,'])
+ assert @store.cache.ttl(key) <= 120
+ end
+
it 'has the class referenced by homonym constant' do
::Rack::Cache::EntityStore::REDIS.must_equal(::Rack::Cache::EntityStore::Redis)
end
it 'resolves the connection uri' do
cache = ::Rack::Cache::EntityStore::Redis.resolve(uri("redis://127.0.0.1")).cache
cache.must_be_kind_of(::Redis)
cache.id.must_equal("redis://127.0.0.1:6379/0")
+
+ cache = ::Rack::Cache::EntityStore::Redis.resolve(uri("rediss://127.0.0.1")).cache
+ cache.must_be_kind_of(::Redis)
+ cache.instance_variable_get(:@client).scheme.must_equal('rediss')
cache = ::Rack::Cache::EntityStore::Redis.resolve(uri("redis://127.0.0.1:6380")).cache
cache.id.must_equal("redis://127.0.0.1:6380/0")
cache = ::Rack::Cache::EntityStore::Redis.resolve(uri("redis://127.0.0.1/13")).cache