Sha256: aff16f289e141add28941a47cf8f75c5d5730cb02512657c33425f9c4bc0e9e9
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' class TestRedis def self.to_s 'Redis' end def initialize @wrapped = {} end def set(key, object) @wrapped[key] = object end def expire(key, seconds) end def [](x) @wrapped[x] end def clear @wrapped.clear end def del(key) @wrapped.delete(key) end end describe "Cachy::RedisWrapper" do let(:yaml_ending) { RUBY_VERSION > '1.9' ? "\n...\n" : "\n" } before :all do @cache = TestRedis.new Cachy.cache_store = @cache end before do @cache.clear end it "is wrapped" do Cachy.cache_store.class.should == Cachy::RedisWrapper end it "can cache" do Cachy.cache(:x){ 'SUCCESS' } Cachy.cache(:x){ 'FAIL' }.should == 'SUCCESS' end it "can cache without expires" do @cache.should_receive(:set).with('x_v1', "--- SUCCESS#{yaml_ending}") @cache.should_not_receive(:expire) Cachy.cache(:x){ 'SUCCESS' }.should == 'SUCCESS' end it "can cache with expires" do @cache.should_receive(:set).with('x_v1', "--- SUCCESS#{yaml_ending}") @cache.should_receive(:expire).with('x_v1', 1) Cachy.cache(:x, :expires_in=>1){ 'SUCCESS' }.should == 'SUCCESS' end it "can expire" do @cache.should_receive(:del).with('x_v1') Cachy.expire(:x) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cachy-0.3.1 | spec/cachy/redis_wrapper_spec.rb |
cachy-0.3.0 | spec/cachy/redis_wrapper_spec.rb |