From 06096e36055ebd4f269060fdc9ad1d9e663834e4 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 22 Nov 2019 18:10:04 +0530 Subject: [PATCH] Simulate `last_modified_at` injection by plugin (#256) Merge pull request 256 --- jekyll-sitemap.gemspec | 1 - spec/test_jekyll-last-modified-at.rb | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jekyll-sitemap.gemspec b/jekyll-sitemap.gemspec index 3bc3789..a9cdeea 100644 --- a/jekyll-sitemap.gemspec +++ b/jekyll-sitemap.gemspec @@ -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" diff --git a/spec/test_jekyll-last-modified-at.rb b/spec/test_jekyll-last-modified-at.rb index 3c0ae79..4387b05 100644 --- a/spec/test_jekyll-last-modified-at.rb +++ b/spec/test_jekyll-last-modified-at.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "spec_helper" -require "jekyll-last-modified-at" describe(Jekyll::JekyllSitemap) do let(:overrides) do @@ -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!http://example.org/2015/01/18/jekyll-last-modified-at.html\s+2015-01-19T07:03:38\+00:00! + expect(contents).to match( + %r! + http://example.org/2015/01/18/jekyll-last-modified-at.html\s+ + 2015-01-18T00:00:00\+00:00 + !x + ) end it "correctly adds the modified time to the pages" do - expect(contents).to match %r!http://example.org/jekyll-last-modified-at/page.html\s+2015-01-19T07:03:38\+00:00! + expect(contents).to match( + %r! + http://example.org/jekyll-last-modified-at/page.html\s+ + 2015-01-18T00:00:00\+00:00 + !x + ) end end end