Sha256: 9b3ad356026c930a5ac3c14d889510fea494f5c977d19bf8856de2a185485bc6

Contents?: true

Size: 1.96 KB

Versions: 8

Compression:

Stored size: 1.96 KB

Contents

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

describe "Lawnchair::StorageEngine::InProcessStore" do
  attr_reader :in_process_store
  
  before do
    @in_process_store = Lawnchair::StorageEngine::InProcess
  end

  describe "#data_store" do
    it "returns the redis cache object" do
      Lawnchair::StorageEngine::InProcess.send(:class_variable_set, "@@data_store", {"Lawnchair:mu" => "fasa"})
      in_process_store.data_store["Lawnchair:mu"].should == "fasa"
    end
  end
  
  describe "#set" do
    context "when raw is true" do  
      it "sets the value" do
        in_process_store.data_store["Lawnchair:mu"].should be_nil
        in_process_store.set("mu", "fasa", :raw => true)
        in_process_store.data_store["Lawnchair:mu"].should == "fasa"
      end
    end
    
    context "when raw is false" do
      it "sets the value" do
        value = "fasa"
        expected_value = Marshal.dump(value)
        
        in_process_store.data_store["Lawnchair:mu"].should be_nil
        in_process_store.set("mu", value, :raw => false)
        in_process_store.data_store["Lawnchair:mu"].should == expected_value
      end
    end
  end
  
  describe "exists?" do
    it "returns false when the key does not exist" do
      in_process_store.data_store.keys.should_not include("Lawnchair:mu")
      in_process_store.exists?("mu").should be_false
    end

    it "returns true when the key exists" do
      in_process_store.data_store["Lawnchair:mu"] = "fasa"
      in_process_store.data_store.keys.should include("Lawnchair:mu")
      in_process_store.exists?("mu").should be_true
    end
  end
  
  describe "#expire!" do
    it "should only expire the key specified" do
      in_process_store.data_store["Lawnchair:mu"] = "fasa"
      in_process_store.data_store["Lawnchair:sim"] = "ba"

      in_process_store.expire!("mu")
      in_process_store.data_store["Lawnchair:mu"].should be_nil
      in_process_store.data_store["Lawnchair:sim"].should == "ba"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lawnchair-0.6.11 spec/storage_engine/in_process_spec.rb
lawnchair-0.6.10 spec/storage_engine/in_process_spec.rb
lawnchair-0.6.9 spec/storage_engine/in_process_spec.rb
lawnchair-0.6.8 spec/storage_engine/in_process_spec.rb
lawnchair-0.6.7 spec/storage_engine/in_process_spec.rb
lawnchair-0.6.6 spec/storage_engine/in_process_spec.rb
lawnchair-0.5.4 spec/storage_engine/in_process_spec.rb
lawnchair-0.5.2 spec/storage_engine/in_process_spec.rb