File: jekyll-include-tag_spec.rb

package info (click to toggle)
ruby-jekyll-include-cache 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 188 kB
  • sloc: ruby: 267; sh: 5; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 847 bytes parent folder | download
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