Sha256: 0d2876489ad6445201a233f348a24468c63a61615a64a90294a155dcd3ebd707

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "spec_helper"

describe "Rails cache integration" do
  subject { Rails.cache }
  let(:cashier) { Cashier }

  it "should ensure that cache operations are instrumented" do
    ActiveSupport::Cache::Store.instrument.should be_true
  end

  context "write" do
    it "should write to cashier when I call Rails.cache.write with tags" do
      cashier.should_receive(:store_fragment).with("foo", ["some_tag"])
      subject.write("foo", "bar", :tag => ["some_tag"])
    end

    it "shuld not write to cashier when I call Rails.cache.write without tags" do
      cashier.should_not_receive(:store_fragment)
      subject.write("foo", "bar")
    end

    it "should not fail when I don't pass in any options" do
      expect { subject.write("foo", "bar", nil) }.to_not raise_error
    end
  end

  context "fetch" do
    it "should write to cashier when I call Rails.cache.fetch with tags" do
      cashier.should_receive(:store_fragment).with("foo", ["some_tag"])
      subject.fetch("foo", :tag => ["some_tag"]) { "bar" }
    end

    it "shuld not write to cashier when I call Rails.cache.fetch without tags" do
      cashier.should_not_receive(:store_fragment)
      subject.fetch("foo") { "bar" }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cashier-0.4.1 spec/integration/rails_cache_integration_spec.rb