Sha256: c8bb0b9ffba151eb7e6c288bfcda0b1221a9305eeff68682605d6ed95f94b4df

Contents?: true

Size: 789 Bytes

Versions: 20

Compression:

Stored size: 789 Bytes

Contents

module Ddr::Models
  RSpec.describe Cache do

    describe "#get" do
      it "retrieves a value by key" do
        expect(subject.get(:foo)).to be_nil
        subject[:foo] = "bar"
        expect(subject.get(:foo)).to eq "bar"
      end
    end

    describe "#put" do
      it "inserts a key/value" do
        expect { subject.put(:foo, "bar") }.to change { subject[:foo] }.from(nil).to("bar")
      end
    end

    describe "#with" do
      it "returns the value of the block" do
        result = subject.with(foo: "bar") { 1 }
        expect(result).to eq 1
      end
      it "temporarily caches the arguments" do
        subject.with(foo: "bar") do
          expect(subject.get(:foo)).to eq "bar"
        end
        expect(subject.get(:foo)).to be_nil
      end
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ddr-models-2.11.0 spec/models/cache_spec.rb
ddr-models-2.10.2 spec/models/cache_spec.rb
ddr-models-2.10.1 spec/models/cache_spec.rb
ddr-models-2.10.0 spec/models/cache_spec.rb
ddr-models-2.10.0.rc2 spec/models/cache_spec.rb
ddr-models-2.10.0.rc1 spec/models/cache_spec.rb
ddr-models-2.9.2 spec/models/cache_spec.rb
ddr-models-2.9.1 spec/models/cache_spec.rb
ddr-models-2.9.0 spec/models/cache_spec.rb
ddr-models-2.9.0.rc1 spec/models/cache_spec.rb
ddr-models-2.8.0 spec/models/cache_spec.rb
ddr-models-2.8.0.rc1 spec/models/cache_spec.rb
ddr-models-2.7.6 spec/models/cache_spec.rb
ddr-models-2.7.5 spec/models/cache_spec.rb
ddr-models-2.7.4 spec/models/cache_spec.rb
ddr-models-2.7.3 spec/models/cache_spec.rb
ddr-models-2.7.2 spec/models/cache_spec.rb
ddr-models-2.7.1 spec/models/cache_spec.rb
ddr-models-2.7.0 spec/models/cache_spec.rb
ddr-models-2.7.0.rc1 spec/models/cache_spec.rb