File: test_jekyll-last-modified-at.rb

package info (click to toggle)
ruby-jekyll-sitemap 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 384 kB
  • sloc: ruby: 365; xml: 39; sh: 19; makefile: 9
file content (50 lines) | stat: -rw-r--r-- 1,404 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
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require "spec_helper"

describe(Jekyll::JekyllSitemap) do
  let(:overrides) do
    {
      "source"      => source_dir,
      "destination" => dest_dir,
      "url"         => "http://example.org",
      "collections" => {
        "my_collection" => { "output" => true },
        "other_things"  => { "output" => false },
      },
    }
  end
  let(:config) do
    Jekyll.configuration(overrides)
  end
  let(:site)     { Jekyll::Site.new(config) }
  let(:contents) { File.read(dest_dir("sitemap.xml")) }
  before(:each) do
    # simulate `last_modified_at` injection by `jekyll-last-modified-at` plugin
    Jekyll::Hooks.register([:pages, :documents], :post_init) do |page|
      page.data["last_modified_at"] = Time.parse("2015-01-18T00:00:00+00:00")
    end

    site.process
  end

  context "with jekyll-last-modified-at" do
    it "correctly adds the modified time to the posts" do
      expect(contents).to match(
        %r!
          <loc>http://example.org/2015/01/18/jekyll-last-modified-at.html</loc>\s+
          <lastmod>2015-01-18T00:00:00\+00:00</lastmod>
        !x
      )
    end

    it "correctly adds the modified time to the pages" do
      expect(contents).to match(
        %r!
          <loc>http://example.org/jekyll-last-modified-at/page.html</loc>\s+
          <lastmod>2015-01-18T00:00:00\+00:00</lastmod>
        !x
      )
    end
  end
end