Sha256: 7cbfd503ece33bb92062e6f622f9a26f4408e0e34e1a7207acd4cce8a9bd35c5

Contents?: true

Size: 831 Bytes

Versions: 2

Compression:

Stored size: 831 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

require 'moneta/memcache'

describe APICache::MonetaStore do
  before :each do
    @moneta = Moneta::Memcache.new(:server => "localhost")
    @moneta.delete('foo')
    @store = APICache::MonetaStore.new(@moneta)
  end

  it "should set and get" do
    @store.set("key", "value")
    @store.get("key").should == "value"
  end

  it "should allow checking whether a key exists" do
    @store.exists?('foo').should be_false
    @store.set('foo', 'bar')
    @store.exists?('foo').should be_true
  end

  it "should allow checking whether a given amount of time has passed since the key was set" do
    @store.expired?('foo', 1).should be_false
    @store.set('foo', 'bar')
    @store.expired?('foo', 1).should be_false
    sleep 1
    @store.expired?('foo', 1).should be_true
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mloughran-api_cache-0.2.0 spec/monteta_store_spec.rb
api_cache-0.2.0 spec/monteta_store_spec.rb