Sha256: 8d53da5d3b7ebf7668876e85a9eef7e4939f6117b9a35f0e8301ac2a6f4c2f47

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require "spec_helper"

shared_examples "a stormy cache" do 

  let(:app) {  StormyApp.new(root: FIXTURE_ROOT + "/dummy_site/",
                             cache: described_class) }

  context "#page" do

    it "stores returns the item in the block" do
      result = app.cache.page("tester") do
        "My Val"
      end

      expect(result).to eq "My Val"
    end

    it "doesn't call the block after it's stored it in the cache" do
      app.cache.page("tester") do
        "Dummy Val"
      end

      result = app.cache.page("tester") do
        raise "Error"
      end

      expect(result).to eq "Dummy Val"
    end
    
  end
end

describe Stormy::Caches::MemoryCache do
  it_behaves_like "a stormy cache"
end

describe Stormy::Caches::FileCache do
  it_behaves_like "a stormy cache"

  it "creates the necessary directory" do
    cache_dir = FIXTURE_ROOT + "/dummy_site/tmp/cache"
    FileUtils.rm_r(cache_dir) rescue nil

    expect(File.directory?(cache_dir)).to eq false
    StormyApp.new(root: FIXTURE_ROOT + "/dummy_site/",
                  cache: described_class)

    expect(File.directory?(cache_dir)).to eq true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stormy-0.0.1 spec/stormy/caches/caches_spec.rb