Sha256: c4881675313d3eb85dfdff0392e5fae5f93a543829d650abc87920b1f520e663
Contents?: true
Size: 1.09 KB
Versions: 11
Compression:
Stored size: 1.09 KB
Contents
require 'spec/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
11 entries across 11 versions & 2 rubygems