1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
# frozen_string_literal: true
RSpec.describe JekyllIncludeCache do
subject { described_class.cache }
context "with an empty cache" do
it "initializess the cache" do
expect(described_class.cache).to respond_to(:[])
expect(described_class.cache).to respond_to(:[]=)
end
end
context "with something cached" do
before { subject["foo"] = "bar" }
it "caches" do
expect(subject.key?("foo")).to be_truthy
end
it "returns the cache" do
expect(subject["foo"]).to eql("bar")
end
end
context "clearing the cache on render" do
let(:site) { fixture_site("site") }
before do
subject["foo"] = "bar"
Jekyll::Hooks.trigger :site, :pre_render, site, site.site_payload
end
it "clears the cache" do
expect(subject.key?("foo")).to_not be_truthy
end
end
end
|