Sha256: 6e6529fe0d34949423e2251613082a947feef097ea21dcb3b2e14cea1bdb504b

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

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

describe "Lawnchair::Cache" do
  describe ".me" do
    it "returns the value if it exists" do
      expected_object = [1,2,3,4]
      Lawnchair::Cache.me("marshalled_array") { expected_object }
      
      x = Lawnchair::Cache.me("marshalled_array") { "JUNK DATA" }
      x.should == expected_object
    end
    
    it "marshalls the object into redis" do
      expected_object = [1,2,3,4]
      Lawnchair::Cache.me("marshalled_array") { expected_object }
      
      Marshal.load(Lawnchair.redis["Lawnchair:marshalled_array"]).should == [1,2,3,4]
    end
    
    describe "when in_process => true" do
      it "fetches the value to/from the composite store" do
        mock_composite_engine = Lawnchair::StorageEngine::Composite.new
        Lawnchair::StorageEngine::Composite.stub!(:new).and_return(mock_composite_engine)
        
        mock_composite_engine.should_receive(:fetch)
        Lawnchair::Cache.me("mu", :in_process => true, :raw => true) { "fasa" }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lawnchair-0.5.2 spec/lawnchair_spec.rb
lawnchair-0.5.1 spec/lawnchair_spec.rb
lawnchair-0.5.0 spec/lawnchair_spec.rb