Sha256: 51b910970ccf0dcab703c9a31762c323e9372eaadf43af6d2a1b2c024407cf93

Contents?: true

Size: 790 Bytes

Versions: 4

Compression:

Stored size: 790 Bytes

Contents

require 'spec/spec_helper'
require 'spec/mem_cache'

describe "Cachy::MemcachedWrapper" do
  before :all do
    @cache = MemCache.new
    Cachy.cache_store = @cache
  end

  before do
    @cache.clear
  end

  it "is wrapped" do
    Cachy.cache_store.class.should == Cachy::MemcachedWrapper
  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', 0)
    Cachy.cache(:x){ 'SUCCESS' }
  end

  it "can cache with expires" do
    @cache.should_receive(:set).with('x_v1', 'SUCCESS', 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

4 entries across 4 versions & 1 rubygems

Version Path
cachy-0.2.1 spec/cachy/memcached_wrapper_spec.rb
cachy-0.2.0 spec/cachy/memcached_wrapper_spec.rb
cachy-0.1.7 spec/cachy/memcached_wrapper_spec.rb
cachy-0.1.6 spec/cachy/memcached_wrapper_spec.rb