Sha256: 72a19d59148e3e2422368463b071a298742dc66ef3b0ee085b81282f2f11eac3

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

require 'spec_helper'

describe ApiResource do

  context ".cache" do

    after(:each) do
      if defined?(Rails)
        Object.send(:remove_const, :Rails)
      end
    end

    it "should be a Rails cache if it's initialized" do
      cache_stub = stub()
      Rails = mock(:cache => cache_stub)
      ApiResource.cache(true).should be cache_stub
    end

    it "should default to an instance of memory cache" do
      defined?(Rails).should be_blank
      ApiResource.cache(true).should be_a(
        ActiveSupport::Cache::MemoryStore
      )
    end
  end

  context ".with_ttl" do

    it "should temporarily set ttl for a block" do
      old_ttl = ApiResource.ttl
      ApiResource.with_ttl(10) do
        ApiResource.ttl.should eql(10)
      end
      ApiResource.ttl.should eql(old_ttl)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_resource-0.5.1 spec/lib/api_resource_spec.rb
api_resource-0.5.0 spec/lib/api_resource_spec.rb