diff --git a/.rubocop.yml b/.rubocop.yml index 1538636a..c2504a32 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -19,10 +19,7 @@ AllCops: - LICENSE.txt - README.md - - features/**/* - script/**/* - - spec/**/* - - test/**/* - vendor/**/* Naming/MemoizedInstanceVariableName: diff --git a/spec/jekyll-feed_spec.rb b/spec/jekyll-feed_spec.rb index e042c425..1a8cc5c7 100644 --- a/spec/jekyll-feed_spec.rb +++ b/spec/jekyll-feed_spec.rb @@ -43,53 +43,53 @@ end it "puts all the posts in the feed.xml file" do - expect(contents).to match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ - expect(contents).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/ - expect(contents).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/ + expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html" + expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html" + expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html" expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html" - expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/ + expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html" end it "does not include assets or any static files that aren't .html" do - expect(contents).not_to match /http:\/\/example\.org\/images\/hubot\.png/ - expect(contents).not_to match /http:\/\/example\.org\/feeds\/atom\.xml/ + expect(contents).not_to match "http://example.org/images/hubot.png" + expect(contents).not_to match "http://example.org/feeds/atom.xml" end it "preserves linebreaks in preformatted text in posts" do - expect(contents).to match %r!Line 1\nLine 2\nLine 3! + expect(contents).to match "Line 1\nLine 2\nLine 3" end it "supports post author name as an object" do - expect(contents).to match /\s*Ben<\/name>\s*ben@example.com<\/email>\s*http:\/\/ben.balter.com<\/uri>\s*<\/author>/ + expect(contents).to match %r!\s*Ben\s*ben@example\.com\s*http://ben\.balter\.com\s*! end it "supports post author name as a string" do - expect(contents).to match /\s*Pat<\/name>\s*<\/author>/ + expect(contents).to match %r!\s*Pat\s*! end it "does not output author tag no author is provided" do - expect(contents).not_to match /\s*<\/name>\s*<\/author>/ + expect(contents).not_to match %r!\s*\s*! end it "does use author reference with data from _data/authors.yml" do - expect(contents).to match /\s*Garth<\/name>\s*example@mail.com<\/email>\s*http:\/\/garthdb.com<\/uri>\s*<\/author>/ + expect(contents).to match %r!\s*Garth\s*example@mail\.com\s*http://garthdb\.com\s*! end it "converts markdown posts to HTML" do - expect(contents).to match /<p>March the second!<\/p>/ + expect(contents).to match %r!<p>March the second\!</p>! end it "uses last_modified_at where available" do - expect(contents).to match /2015-05-12T13:27:59\+00:00<\/updated>/ + expect(contents).to match %r!2015-05-12T13:27:59\+00:00! end it "replaces newlines in posts to spaces" do - expect(contents).to match %r!The plugin will properly strip newlines.! + expect(contents).to match 'The plugin will properly strip newlines.' end it "renders Liquid inside posts" do - expect(contents).to match %r!Liquid is rendered\.! - expect(contents).not_to match %r!Liquid is not rendered\.! + expect(contents).to match "Liquid is rendered." + expect(contents).not_to match "Liquid is not rendered." end it "includes the item image" do @@ -239,9 +239,9 @@ end it "correctly adds the baseurl to the posts" do - expect(contents).to match /http:\/\/example\.org\/bass\/updates\/2014\/03\/04\/march-the-fourth\.html/ - expect(contents).to match /http:\/\/example\.org\/bass\/news\/2014\/03\/02\/march-the-second\.html/ - expect(contents).to match /http:\/\/example\.org\/bass\/news\/2013\/12\/12\/dec-the-second\.html/ + expect(contents).to match "http://example.org/bass/updates/2014/03/04/march-the-fourth.html" + expect(contents).to match "http://example.org/bass/news/2014/03/02/march-the-second.html" + expect(contents).to match "http://example.org/bass/news/2013/12/12/dec-the-second.html" end it "renders the feed meta" do @@ -258,11 +258,11 @@ context "with a blank site name" do let(:config) do - Jekyll.configuration({ + Jekyll.configuration( "source" => source_dir, "destination" => dest_dir, - "url" => "http://example.org", - }) + "url" => "http://example.org" + ) end it "does not output blank title" do @@ -296,9 +296,9 @@ "feed" => { "collections" => { "posts" => { - "path" => "atom.xml" - } - } + "path" => "atom.xml", + }, + }, }, } end @@ -323,70 +323,70 @@ let(:overrides) { { "lang" => "en-US" } } it "should set the language" do - expect(contents).to match %r!type="text/html" hreflang="en-US" />! + expect(contents).to match 'type="text/html" hreflang="en-US" />' end end context "with post.lang set" do it "should set the language for that entry" do - expect(contents).to match %r!! - expect(contents).to match %r!! + expect(contents).to match '' + expect(contents).to match '' end end context "categories" do context "with top-level post categories" do - let(:overrides) { + let(:overrides) do { - "feed" => { "categories" => ["news"] } + "feed" => { "categories" => ["news"] }, } - } + end let(:news_feed) { File.read(dest_dir("feed/news.xml")) } it "outputs the primary feed" do - expect(contents).to match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ - expect(contents).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/ - expect(contents).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/ + expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html" + expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html" + expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html" expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html" - expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/ + expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html" end it "outputs the category feed" do - expect(news_feed).to match "My awesome site | News" - expect(news_feed).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/ - expect(news_feed).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/ - expect(news_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ + expect(news_feed).to match 'My awesome site | News' + expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html" + expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html" + expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html" expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html" end end context "with collection-level post categories" do - let(:overrides) { + let(:overrides) do { "feed" => { "collections" => { "posts" => { - "categories" => ["news"] - } - } - } + "categories" => ["news"], + }, + }, + }, } - } + end let(:news_feed) { File.read(dest_dir("feed/news.xml")) } it "outputs the primary feed" do - expect(contents).to match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ - expect(contents).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/ - expect(contents).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/ + expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html" + expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html" + expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html" expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html" - expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/ + expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html" end it "outputs the category feed" do - expect(news_feed).to match "My awesome site | News" - expect(news_feed).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/ - expect(news_feed).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/ - expect(news_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ + expect(news_feed).to match 'My awesome site | News' + expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html" + expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html" + expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html" expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html" end end @@ -396,73 +396,72 @@ let(:collection_feed) { File.read(dest_dir("feed/collection.xml")) } context "when initialized as an array" do - let(:overrides) { + let(:overrides) do { "collections" => { "collection" => { - "output" => true - } + "output" => true, + }, }, - "feed" => { "collections" => ["collection"] } + "feed" => { "collections" => ["collection"] }, } - } - + end it "outputs the collection feed" do - expect(collection_feed).to match "My awesome site | Collection" + expect(collection_feed).to match 'My awesome site | Collection' expect(collection_feed).to match "http://example.org/collection/2018-01-01-collection-doc.html" expect(collection_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html" - expect(collection_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ + expect(collection_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html" expect(collection_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html" end end context "with categories" do - let(:overrides) { + let(:overrides) do { "collections" => { "collection" => { - "output" => true - } + "output" => true, + }, }, - "feed" => { + "feed" => { "collections" => { "collection" => { - "categories" => ["news"] - } - } - } + "categories" => ["news"], + }, + }, + }, } - } + end let(:news_feed) { File.read(dest_dir("feed/collection/news.xml")) } it "outputs the collection category feed" do - expect(news_feed).to match "My awesome site | Collection | News" + expect(news_feed).to match 'My awesome site | Collection | News' expect(news_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html" expect(news_feed).to_not match "http://example.org/collection/2018-01-01-collection-doc.html" - expect(news_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/ + expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html" expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html" end end context "with a custom path" do - let(:overrides) { + let(:overrides) do { "collections" => { "collection" => { - "output" => true - } + "output" => true, + }, }, - "feed" => { + "feed" => { "collections" => { "collection" => { "categories" => ["news"], - "path" => "custom.xml" - } - } - } + "path" => "custom.xml", + }, + }, + }, } - } + end it "should write to the custom path" do expect(Pathname.new(dest_dir("custom.xml"))).to exist