Skip to content

Commit

Permalink
Simulate last_modified_at injection by plugin (#256)
Browse files Browse the repository at this point in the history
Merge pull request 256
  • Loading branch information
ashmaroli authored and jekyllbot committed Nov 22, 2019
1 parent 5aef94e commit 06096e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion jekyll-sitemap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
spec.add_dependency "jekyll", ">= 3.7", "< 5.0"

spec.add_development_dependency "bundler"
spec.add_development_dependency "jekyll-last-modified-at", "~> 1.0"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop-jekyll", "~> 0.4"
Expand Down
20 changes: 17 additions & 3 deletions spec/test_jekyll-last-modified-at.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "spec_helper"
require "jekyll-last-modified-at"

describe(Jekyll::JekyllSitemap) do
let(:overrides) do
Expand All @@ -21,16 +20,31 @@
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-19T07:03:38\+00:00</lastmod>!
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-19T07:03:38\+00:00</lastmod>!
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

0 comments on commit 06096e3

Please sign in to comment.