Sha256: f797d90605eacc9260f40fd5c991178eaff240174e40582db03fef1ba51847a2

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 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("marshalled_array") { expected_object }
      
      x = Lawnchair.cache("marshalled_array") { "JUNK DATA" }
      x.should == expected_object
    end
    
    it "marshalls the object into redis" do
      expected_object = [1,2,3,4]
      Lawnchair.cache("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("mu", :in_process => true, :raw => true) { "fasa" }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lawnchair-0.6.2 spec/lawnchair_spec.rb
lawnchair-0.6.0 spec/lawnchair_spec.rb
lawnchair-0.5.7 spec/lawnchair_spec.rb
lawnchair-0.5.6 spec/lawnchair_spec.rb
lawnchair-0.5.5 spec/lawnchair_spec.rb
lawnchair-0.5.4 spec/lawnchair_spec.rb