jekyll-feed 0.11.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/History.markdown +49 -2
  3. data/README.md +63 -1
  4. data/lib/jekyll-feed/feed.xml +25 -6
  5. data/lib/jekyll-feed/generator.rb +32 -3
  6. data/lib/jekyll-feed/meta-tag.rb +1 -1
  7. data/lib/jekyll-feed/version.rb +1 -1
  8. metadata +30 -72
  9. data/.gitignore +0 -20
  10. data/.rspec +0 -2
  11. data/.rubocop.yml +0 -28
  12. data/.travis.yml +0 -25
  13. data/Gemfile +0 -8
  14. data/Rakefile +0 -8
  15. data/jekyll-feed.gemspec +0 -30
  16. data/script/bootstrap +0 -3
  17. data/script/cibuild +0 -7
  18. data/script/fmt +0 -10
  19. data/script/release +0 -7
  20. data/script/test +0 -4
  21. data/spec/fixtures/_collection/2018-01-01-collection-doc.md +0 -4
  22. data/spec/fixtures/_collection/2018-01-02-collection-category-doc.md +0 -5
  23. data/spec/fixtures/_config.yml +0 -9
  24. data/spec/fixtures/_data/authors.yml +0 -5
  25. data/spec/fixtures/_drafts/2015-01-12-a-draft.md +0 -4
  26. data/spec/fixtures/_layouts/some_default.html +0 -11
  27. data/spec/fixtures/_posts/2013-12-12-dec-the-second.md +0 -7
  28. data/spec/fixtures/_posts/2014-03-02-march-the-second.md +0 -6
  29. data/spec/fixtures/_posts/2014-03-04-march-the-fourth.md +0 -9
  30. data/spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md +0 -5
  31. data/spec/fixtures/_posts/2015-02-12-strip-newlines.md +0 -6
  32. data/spec/fixtures/_posts/2015-05-12-liquid.md +0 -7
  33. data/spec/fixtures/_posts/2015-05-12-pre.html +0 -8
  34. data/spec/fixtures/_posts/2015-05-18-author-detail.md +0 -9
  35. data/spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html +0 -2
  36. data/spec/fixtures/_posts/2016-04-25-author-reference.md +0 -6
  37. data/spec/fixtures/feed.xslt.xml +0 -0
  38. data/spec/jekyll-feed_spec.rb +0 -474
  39. data/spec/spec_helper.rb +0 -30
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- /vendor
2
- /.bundle/
3
- /.yardoc
4
- /Gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
11
- *.bundle
12
- *.so
13
- *.o
14
- *.a
15
- mkmf.log
16
- *.gem
17
- Gemfile.lock
18
- spec/dest
19
- .bundle
20
- spec/fixtures/.jekyll-metadata
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --format progress
@@ -1,28 +0,0 @@
1
- inherit_gem:
2
- jekyll: .rubocop.yml
3
-
4
- AllCops:
5
- TargetRubyVersion: 2.3
6
- Include:
7
- - lib/**/*.rb
8
-
9
- Exclude:
10
- - .gitignore
11
- - .rspec
12
- - .rubocop.yml
13
- - .travis.yml
14
-
15
- - Gemfile.lock
16
- - History.markdown
17
- - LICENSE.txt
18
- - README.md
19
-
20
- - features/**/*
21
- - script/**/*
22
- - spec/**/*
23
- - test/**/*
24
- - vendor/**/*
25
-
26
- Naming/MemoizedInstanceVariableName:
27
- Exclude:
28
- - lib/jekyll-feed/page-without-a-file.rb
@@ -1,25 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- rvm:
5
- - 2.5
6
- - 2.4
7
- - 2.3
8
- env:
9
- global:
10
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
11
- before_install:
12
- - gem update --system
13
- - gem install bundler
14
- before_script: bundle update
15
- script: script/cibuild
16
- notifications:
17
- email: false
18
- deploy:
19
- provider: rubygems
20
- api_key:
21
- secure: qz0q6ur0kGo03jjLdoAak6WcEAwxX2r9LG3DVrhOrcfoFipkuW+uwR0et4tpK8uFrz0P9y7eTIKOb0XCXeIsIXWj6R5benpRGr2U8m9A+tE/jxviBFUaxaokte0lqWiX1fEyhRmW3zvcdLQ47Vd2EwTNaq6ZmPulmEe9gS0rBQghyclakGlZ17LI7oGgiNL9SQ335Yqa1qJklTHYHbodWQ3Z07v7VN2jxqi3WH6NacT5gUGp5iCNCLLa8+jpKr4uONNIoy6/geAWdqtvgGUE8oTjIWDoJarrknJpqfx9Rd0KLDzkyneAigHDYPW60QtrE6GGpK/+TF1pF4DzdK2EgTWqGFnZf8ehfnxmtHVl2Xq/DPr6hS8Q/f+ut4ioMzBQxPD0hfh8/EOMYKsO8mOuOlYTiZXC7iuGyvFUOl2hnBgWA99t+I0NNB06qFp3ZxIjolEc3zjzc9f1a5HUXlEut5V8nqvCwbctNiTVpT8ZEWlsQlyRUnr9cIMUTEfLgQ+v6DnvAJBMO1EILq6liB5qfutjNhzhlREt7P/ZdppGsAzWpgt0q2PafqVoPe62WR3+/8Lj2ErMr034xSSqZVNcBS0mbdvW6k3jaABo1VJ4XuHm6/yDuemWzWb7kdG9/14+IIJMW1VuaWcmnCnB6gxjkCW3Dm2ftYiN7Rfn3AUz/nU=
22
- gem: jekyll-feed
23
- on:
24
- tags: true
25
- repo: jekyll/jekyll-feed
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- gemspec
5
-
6
- if ENV["JEKYLL_VERSION"]
7
- gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
8
- end
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => :spec
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "jekyll-feed/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "jekyll-feed"
9
- spec.version = Jekyll::Feed::VERSION
10
- spec.authors = ["Ben Balter"]
11
- spec.email = ["ben.balter@github.com"]
12
- spec.summary = "A Jekyll plugin to generate an Atom feed of your Jekyll posts"
13
- spec.homepage = "https://github.com/jekyll/jekyll-feed"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
19
- spec.require_paths = ["lib"]
20
-
21
- spec.required_ruby_version = ">= 2.3.0"
22
-
23
- spec.add_dependency "jekyll", "~> 3.3"
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "nokogiri", "~> 1.6"
26
- spec.add_development_dependency "rake", "~> 12.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
28
- spec.add_development_dependency "rubocop", "~> 0.57.2"
29
- spec.add_development_dependency "typhoeus", ">= 0.7", "< 2.0"
30
- end
@@ -1,3 +0,0 @@
1
- #! /bin/bash
2
-
3
- bundle install
@@ -1,7 +0,0 @@
1
- #! /bin/bash
2
-
3
- set -e
4
-
5
- script/test
6
- script/fmt
7
- bundle exec rake build
data/script/fmt DELETED
@@ -1,10 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- echo "Rubocop $(bundle exec rubocop --version)"
5
- bundle exec rubocop -D -E $@
6
- success=$?
7
- if ((success != 0)); then
8
- echo -e "\nTry running \`script/fmt -a\` to automatically fix errors"
9
- fi
10
- exit $success
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
- # Tag and push a release.
3
-
4
- set -e
5
-
6
- script/cibuild
7
- bundle exec rake release
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
- set -ex
3
-
4
- bundle exec rspec "$@"
@@ -1,4 +0,0 @@
1
- ---
2
- ---
3
-
4
- Look at me! I'm a collection!
@@ -1,5 +0,0 @@
1
- ---
2
- category: news
3
- ---
4
-
5
- Look at me! I'm a collection doc in a category!
@@ -1,9 +0,0 @@
1
- timezone: UTC
2
-
3
- defaults:
4
- -
5
- scope:
6
- path: ""
7
- type: page
8
- values:
9
- layout: some_default
@@ -1,5 +0,0 @@
1
- garthdb:
2
- name: Garth
3
- twitter: garthdb
4
- uri: "http://garthdb.com"
5
- email: example@mail.com
@@ -1,4 +0,0 @@
1
- ---
2
- ---
3
-
4
- This is a draft.
@@ -1,11 +0,0 @@
1
- ---
2
- ---
3
- <html>
4
- <head>
5
- {% feed_meta %}
6
- </head>
7
- <body>
8
- THIS IS MY LAYOUT
9
- {{ content }}
10
- </body>
11
- </html>
@@ -1,7 +0,0 @@
1
- ---
2
- excerpt: "Foo"
3
- image: "/image.png"
4
- category: news
5
- ---
6
-
7
- # December the twelfth, actually.
@@ -1,6 +0,0 @@
1
- ---
2
- image: https://cdn.example.org/absolute.png?h=188&w=250
3
- category: news
4
- ---
5
-
6
- March the second!
@@ -1,9 +0,0 @@
1
- ---
2
- tags:
3
- - '"/><VADER>'
4
- image:
5
- path: "/object-image.png"
6
- category: updates
7
- ---
8
-
9
- March the fourth!
@@ -1,5 +0,0 @@
1
- ---
2
- last_modified_at: 2015-05-12T13:27:59+00:00
3
- ---
4
-
5
- Please don't modify this file. It's modified time is important.
@@ -1,6 +0,0 @@
1
- ---
2
- title:
3
- The plugin
4
- will properly
5
- strip newlines.
6
- ---
@@ -1,7 +0,0 @@
1
- ---
2
- ---
3
-
4
- {% capture liquidstring %}
5
- Liquid is not rendered.
6
- {% endcapture %}
7
- {{ liquidstring | replace:'not ','' }}
@@ -1,8 +0,0 @@
1
- ---
2
- author: Pat
3
- lang: en
4
- ---
5
-
6
- <pre>Line 1
7
- Line 2
8
- Line 3</pre>
@@ -1,9 +0,0 @@
1
- ---
2
- excerpt: ""
3
- author:
4
- name: Ben
5
- uri: "http://ben.balter.com"
6
- email: ben@example.com
7
- ---
8
-
9
- # December the twelfth, actually.
@@ -1,6 +0,0 @@
1
- ---
2
- excerpt: ""
3
- author: garthdb
4
- ---
5
-
6
- # April the twenty-fifth?
File without changes
@@ -1,474 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe(JekyllFeed) do
6
- let(:overrides) { {} }
7
- let(:config) do
8
- Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
9
- "full_rebuild" => true,
10
- "source" => source_dir,
11
- "destination" => dest_dir,
12
- "show_drafts" => true,
13
- "url" => "http://example.org",
14
- "name" => "My awesome site",
15
- "author" => {
16
- "name" => "Dr. Jekyll",
17
- },
18
- "collections" => {
19
- "my_collection" => { "output" => true },
20
- "other_things" => { "output" => false },
21
- },
22
- }, overrides))
23
- end
24
- let(:site) { Jekyll::Site.new(config) }
25
- let(:contents) { File.read(dest_dir("feed.xml")) }
26
- let(:context) { make_context(:site => site) }
27
- let(:feed_meta) { Liquid::Template.parse("{% feed_meta %}").render!(context, {}) }
28
- before(:each) do
29
- site.process
30
- end
31
-
32
- it "has no layout" do
33
- expect(contents).not_to match(%r!\ATHIS IS MY LAYOUT!)
34
- end
35
-
36
- it "creates a feed.xml file" do
37
- expect(Pathname.new(dest_dir("feed.xml"))).to exist
38
- end
39
-
40
- it "doesn't have multiple new lines or trailing whitespace" do
41
- expect(contents).to_not match %r!\s+\n!
42
- expect(contents).to_not match %r!\n{2,}!
43
- end
44
-
45
- it "puts all the posts in the feed.xml file" do
46
- expect(contents).to match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
47
- expect(contents).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/
48
- expect(contents).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/
49
- expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
50
- expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/
51
- end
52
-
53
- it "does not include assets or any static files that aren't .html" do
54
- expect(contents).not_to match /http:\/\/example\.org\/images\/hubot\.png/
55
- expect(contents).not_to match /http:\/\/example\.org\/feeds\/atom\.xml/
56
- end
57
-
58
- it "preserves linebreaks in preformatted text in posts" do
59
- expect(contents).to match %r!Line 1\nLine 2\nLine 3!
60
- end
61
-
62
- it "supports post author name as an object" do
63
- expect(contents).to match /<author>\s*<name>Ben<\/name>\s*<email>ben@example.com<\/email>\s*<uri>http:\/\/ben.balter.com<\/uri>\s*<\/author>/
64
- end
65
-
66
- it "supports post author name as a string" do
67
- expect(contents).to match /<author>\s*<name>Pat<\/name>\s*<\/author>/
68
- end
69
-
70
- it "does not output author tag no author is provided" do
71
- expect(contents).not_to match /<author>\s*<name><\/name>\s*<\/author>/
72
- end
73
-
74
- it "does use author reference with data from _data/authors.yml" do
75
- expect(contents).to match /<author>\s*<name>Garth<\/name>\s*<email>example@mail.com<\/email>\s*<uri>http:\/\/garthdb.com<\/uri>\s*<\/author>/
76
- end
77
-
78
- it "converts markdown posts to HTML" do
79
- expect(contents).to match /&lt;p&gt;March the second!&lt;\/p&gt;/
80
- end
81
-
82
- it "uses last_modified_at where available" do
83
- expect(contents).to match /<updated>2015-05-12T13:27:59\+00:00<\/updated>/
84
- end
85
-
86
- it "replaces newlines in posts to spaces" do
87
- expect(contents).to match %r!<title type="html">The plugin will properly strip newlines.</title>!
88
- end
89
-
90
- it "renders Liquid inside posts" do
91
- expect(contents).to match %r!Liquid is rendered\.!
92
- expect(contents).not_to match %r!Liquid is not rendered\.!
93
- end
94
-
95
- it "includes the item image" do
96
- expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/image.png" />')
97
- expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://cdn.example.org/absolute.png?h=188&amp;w=250" />')
98
- expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/object-image.png" />')
99
- end
100
-
101
- context "parsing" do
102
- let(:feed) { RSS::Parser.parse(contents) }
103
-
104
- it "outputs an RSS feed" do
105
- expect(feed.feed_type).to eql("atom")
106
- expect(feed.feed_version).to eql("1.0")
107
- expect(feed.encoding).to eql("UTF-8")
108
- expect(feed.lang).to be_nil
109
- expect(feed.valid?).to eql(true)
110
- end
111
-
112
- it "outputs the link" do
113
- expect(feed.link.href).to eql("http://example.org/feed.xml")
114
- end
115
-
116
- it "outputs the generator" do
117
- expect(feed.generator.content).to eql("Jekyll")
118
- expect(feed.generator.version).to eql(Jekyll::VERSION)
119
- end
120
-
121
- it "includes the items" do
122
- expect(feed.items.count).to eql(10)
123
- end
124
-
125
- it "includes item contents" do
126
- post = feed.items.last
127
- expect(post.title.content).to eql("Dec The Second")
128
- expect(post.link.href).to eql("http://example.org/news/2013/12/12/dec-the-second.html")
129
- expect(post.published.content).to eql(Time.parse("2013-12-12"))
130
- end
131
-
132
- it "includes the item's excerpt" do
133
- post = feed.items.last
134
- expect(post.summary.content).to eql("Foo")
135
- end
136
-
137
- it "doesn't include the item's excerpt if blank" do
138
- post = feed.items.first
139
- expect(post.summary).to be_nil
140
- end
141
-
142
- context "with site.lang set" do
143
- lang = "en_US"
144
- let(:overrides) { { "lang" => lang } }
145
- it "outputs a valid feed" do
146
- expect(feed.feed_type).to eql("atom")
147
- expect(feed.feed_version).to eql("1.0")
148
- expect(feed.encoding).to eql("UTF-8")
149
- expect(feed.valid?).to eql(true)
150
- end
151
-
152
- it "outputs the correct language" do
153
- expect(feed.lang).to eql(lang)
154
- end
155
-
156
- it "sets the language of entries" do
157
- post = feed.items.first
158
- expect(post.lang).to eql(lang)
159
- end
160
-
161
- it "renders the feed meta" do
162
- expected = %r!<link href="http://example.org/" rel="alternate" type="text/html" hreflang="#{lang}" />!
163
- expect(contents).to match(expected)
164
- end
165
- end
166
-
167
- context "with site.title set" do
168
- let(:site_title) { "My Site Title" }
169
- let(:overrides) { { "title" => site_title } }
170
-
171
- it "uses site.title for the title" do
172
- expect(feed.title.content).to eql(site_title)
173
- end
174
- end
175
-
176
- context "with site.name set" do
177
- let(:site_name) { "My Site Name" }
178
- let(:overrides) { { "name" => site_name } }
179
-
180
- it "uses site.name for the title" do
181
- expect(feed.title.content).to eql(site_name)
182
- end
183
- end
184
-
185
- context "with site.name and site.title set" do
186
- let(:site_title) { "My Site Title" }
187
- let(:site_name) { "My Site Name" }
188
- let(:overrides) { { "title" => site_title, "name" => site_name } }
189
-
190
- it "uses site.title for the title, dropping site.name" do
191
- expect(feed.title.content).to eql(site_title)
192
- end
193
- end
194
- end
195
-
196
- context "smartify" do
197
- let(:site_title) { "Pat's Site" }
198
- let(:overrides) { { "title" => site_title } }
199
- let(:feed) { RSS::Parser.parse(contents) }
200
-
201
- it "processes site title with SmartyPants" do
202
- expect(feed.title.content).to eql("Pat’s Site")
203
- end
204
- end
205
-
206
- context "validation" do
207
- it "validates" do
208
- # See https://validator.w3.org/docs/api.html
209
- url = "https://validator.w3.org/feed/check.cgi?output=soap12"
210
- response = Typhoeus.post(url, :body => { :rawdata => contents }, :accept_encoding => "gzip")
211
- pending "Something went wrong with the W3 validator" unless response.success?
212
- result = Nokogiri::XML(response.body)
213
- result.remove_namespaces!
214
-
215
- result.css("warning").each do |warning|
216
- # Quiet a warning that results from us passing the feed as a string
217
- next if warning.css("text").text =~ %r!Self reference doesn't match document location!
218
-
219
- # Quiet expected warning that results from blank summary test case
220
- next if warning.css("text").text =~ %r!(content|summary) should not be blank!
221
-
222
- # Quiet expected warning about multiple posts with same updated time
223
- next if warning.css("text").text =~ %r!Two entries with the same value for atom:updated!
224
-
225
- warn "Validation warning: #{warning.css("text").text} on line #{warning.css("line").text} column #{warning.css("column").text}"
226
- end
227
-
228
- errors = result.css("error").map do |error|
229
- "Validation error: #{error.css("text").text} on line #{error.css("line").text} column #{error.css("column").text}"
230
- end
231
-
232
- expect(result.css("validity").text).to eql("true"), errors.join("\n")
233
- end
234
- end
235
-
236
- context "with a baseurl" do
237
- let(:overrides) do
238
- { "baseurl" => "/bass" }
239
- end
240
-
241
- it "correctly adds the baseurl to the posts" do
242
- expect(contents).to match /http:\/\/example\.org\/bass\/updates\/2014\/03\/04\/march-the-fourth\.html/
243
- expect(contents).to match /http:\/\/example\.org\/bass\/news\/2014\/03\/02\/march-the-second\.html/
244
- expect(contents).to match /http:\/\/example\.org\/bass\/news\/2013\/12\/12\/dec-the-second\.html/
245
- end
246
-
247
- it "renders the feed meta" do
248
- expected = 'href="http://example.org/bass/feed.xml"'
249
- expect(feed_meta).to include(expected)
250
- end
251
- end
252
-
253
- context "feed meta" do
254
- it "renders the feed meta" do
255
- expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/feed.xml" title="My awesome site" />'
256
- expect(feed_meta).to eql(expected)
257
- end
258
-
259
- context "with a blank site name" do
260
- let(:config) do
261
- Jekyll.configuration({
262
- "source" => source_dir,
263
- "destination" => dest_dir,
264
- "url" => "http://example.org",
265
- })
266
- end
267
-
268
- it "does not output blank title" do
269
- expect(feed_meta).not_to include("title=")
270
- end
271
- end
272
- end
273
-
274
- context "changing the feed path" do
275
- let(:overrides) do
276
- {
277
- "feed" => {
278
- "path" => "atom.xml",
279
- },
280
- }
281
- end
282
-
283
- it "should write to atom.xml" do
284
- expect(Pathname.new(dest_dir("atom.xml"))).to exist
285
- end
286
-
287
- it "renders the feed meta with custom feed path" do
288
- expected = 'href="http://example.org/atom.xml"'
289
- expect(feed_meta).to include(expected)
290
- end
291
- end
292
-
293
- context "changing the file path via collection meta" do
294
- let(:overrides) do
295
- {
296
- "feed" => {
297
- "collections" => {
298
- "posts" => {
299
- "path" => "atom.xml"
300
- }
301
- }
302
- },
303
- }
304
- end
305
-
306
- it "should write to atom.xml" do
307
- expect(Pathname.new(dest_dir("atom.xml"))).to exist
308
- end
309
-
310
- it "renders the feed meta with custom feed path" do
311
- expected = 'href="http://example.org/atom.xml"'
312
- expect(feed_meta).to include(expected)
313
- end
314
- end
315
-
316
- context "feed stylesheet" do
317
- it "includes the stylesheet" do
318
- expect(contents).to include('<?xml-stylesheet type="text/xml" href="http://example.org/feed.xslt.xml"?>')
319
- end
320
- end
321
-
322
- context "with site.lang set" do
323
- let(:overrides) { { "lang" => "en-US" } }
324
-
325
- it "should set the language" do
326
- expect(contents).to match %r!type="text/html" hreflang="en-US" />!
327
- end
328
- end
329
-
330
- context "with post.lang set" do
331
- it "should set the language for that entry" do
332
- expect(contents).to match %r!<entry xml:lang="en">!
333
- expect(contents).to match %r!<entry>!
334
- end
335
- end
336
-
337
- context "categories" do
338
- context "with top-level post categories" do
339
- let(:overrides) {
340
- {
341
- "feed" => { "categories" => ["news"] }
342
- }
343
- }
344
- let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
345
-
346
- it "outputs the primary feed" do
347
- expect(contents).to match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
348
- expect(contents).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/
349
- expect(contents).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/
350
- expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
351
- expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/
352
- end
353
-
354
- it "outputs the category feed" do
355
- expect(news_feed).to match "<title type=\"html\">My awesome site | News</title>"
356
- expect(news_feed).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/
357
- expect(news_feed).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/
358
- expect(news_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
359
- expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
360
- end
361
- end
362
-
363
- context "with collection-level post categories" do
364
- let(:overrides) {
365
- {
366
- "feed" => {
367
- "collections" => {
368
- "posts" => {
369
- "categories" => ["news"]
370
- }
371
- }
372
- }
373
- }
374
- }
375
- let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
376
-
377
- it "outputs the primary feed" do
378
- expect(contents).to match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
379
- expect(contents).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/
380
- expect(contents).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/
381
- expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
382
- expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/
383
- end
384
-
385
- it "outputs the category feed" do
386
- expect(news_feed).to match "<title type=\"html\">My awesome site | News</title>"
387
- expect(news_feed).to match /http:\/\/example\.org\/news\/2014\/03\/02\/march-the-second\.html/
388
- expect(news_feed).to match /http:\/\/example\.org\/news\/2013\/12\/12\/dec-the-second\.html/
389
- expect(news_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
390
- expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
391
- end
392
- end
393
- end
394
-
395
- context "collections" do
396
- let(:collection_feed) { File.read(dest_dir("feed/collection.xml")) }
397
-
398
- context "when initialized as an array" do
399
- let(:overrides) {
400
- {
401
- "collections" => {
402
- "collection" => {
403
- "output" => true
404
- }
405
- },
406
- "feed" => { "collections" => ["collection"] }
407
- }
408
- }
409
-
410
-
411
- it "outputs the collection feed" do
412
- expect(collection_feed).to match "<title type=\"html\">My awesome site | Collection</title>"
413
- expect(collection_feed).to match "http://example.org/collection/2018-01-01-collection-doc.html"
414
- expect(collection_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
415
- expect(collection_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
416
- expect(collection_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
417
- end
418
- end
419
-
420
- context "with categories" do
421
- let(:overrides) {
422
- {
423
- "collections" => {
424
- "collection" => {
425
- "output" => true
426
- }
427
- },
428
- "feed" => {
429
- "collections" => {
430
- "collection" => {
431
- "categories" => ["news"]
432
- }
433
- }
434
- }
435
- }
436
- }
437
- let(:news_feed) { File.read(dest_dir("feed/collection/news.xml")) }
438
-
439
- it "outputs the collection category feed" do
440
- expect(news_feed).to match "<title type=\"html\">My awesome site | Collection | News</title>"
441
- expect(news_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
442
- expect(news_feed).to_not match "http://example.org/collection/2018-01-01-collection-doc.html"
443
- expect(news_feed).to_not match /http:\/\/example\.org\/updates\/2014\/03\/04\/march-the-fourth\.html/
444
- expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
445
- end
446
- end
447
-
448
- context "with a custom path" do
449
- let(:overrides) {
450
- {
451
- "collections" => {
452
- "collection" => {
453
- "output" => true
454
- }
455
- },
456
- "feed" => {
457
- "collections" => {
458
- "collection" => {
459
- "categories" => ["news"],
460
- "path" => "custom.xml"
461
- }
462
- }
463
- }
464
- }
465
- }
466
-
467
- it "should write to the custom path" do
468
- expect(Pathname.new(dest_dir("custom.xml"))).to exist
469
- expect(Pathname.new(dest_dir("feed/collection.xml"))).to_not exist
470
- expect(Pathname.new(dest_dir("feed/collection/news.xml"))).to exist
471
- end
472
- end
473
- end
474
- end