discourse/spec/lib/redis_store_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
958 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-09-24 20:47:35 +08:00
require 'cache'
RSpec.describe "Redis Store" do
2013-09-24 20:47:35 +08:00
let :cache do
Cache.new(namespace: 'foo')
2013-09-24 20:47:35 +08:00
end
let :store do
DiscourseRedis.new_redis_store
end
before(:each) do
cache.redis.del "key"
store.delete "key"
end
it "can store stuff" do
store.fetch "key" do
"key in store"
end
r = store.read "key"
2015-01-10 00:34:37 +08:00
expect(r).to eq("key in store")
2013-09-24 20:47:35 +08:00
end
it "doesn't collide with our Cache" do
2013-09-24 20:47:35 +08:00
store.fetch "key" do
"key in store"
end
2013-09-24 20:47:35 +08:00
cache.fetch "key" do
"key in cache"
end
2013-09-24 20:47:35 +08:00
r = store.read "key"
2015-01-10 00:34:37 +08:00
expect(r).to eq("key in store")
2013-09-24 20:47:35 +08:00
end
it "can be cleared without clearing our cache" do
cache.clear
store.clear
2013-09-24 20:47:35 +08:00
store.fetch "key" do
"key in store"
end
cache.fetch "key" do
"key in cache"
end
store.clear
2015-01-10 00:34:37 +08:00
expect(store.read("key")).to eq(nil)
expect(cache.fetch("key")).to eq("key in cache")
2013-09-24 20:47:35 +08:00
end
end