Sha256: ad11a1407718996aac05c44d5a241cea2292f7488d70a9cd39912db56c844062
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
require 'spec_helper' class TestMoneta def initialize @wrapped = {} end def store(key, object, options={}) raise 'nope!' if options[:expires_in] and not options[:expires_in].is_a? Numeric @wrapped[key] = object end def [](x) @wrapped[x] end def clear @wrapped.clear end def delete(key) @wrapped.delete(key) end end describe "Cachy::MonetaWrapper" do before :all do @cache = TestMoneta.new Cachy.cache_store = @cache end before do @cache.clear end it "is wrapped" do Cachy.cache_store.class.should == Cachy::MonetaWrapper 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(:store).with('x_v1', 'SUCCESS', {}) Cachy.cache(:x){ 'SUCCESS' } end it "can cache with expires" do @cache.should_receive(:store).with('x_v1', 'SUCCESS', :expires_in=>1) Cachy.cache(:x, :expires_in=>1){ 'SUCCESS' } end it "can expire" do @cache.should_receive(:delete).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/moneta_wrapper_spec.rb |
cachy-0.3.0 | spec/cachy/moneta_wrapper_spec.rb |