Skip to content

Commit b00b0bf

Browse files
authored
style: fix offenses in specs (#248)
Merge pull request 248
1 parent 3f4f491 commit b00b0bf

File tree

2 files changed

+80
-84
lines changed

2 files changed

+80
-84
lines changed

.rubocop.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ AllCops:
1919
- LICENSE.txt
2020
- README.md
2121

22-
- features/**/*
2322
- script/**/*
24-
- spec/**/*
25-
- test/**/*
2623
- vendor/**/*
2724

2825
Naming/MemoizedInstanceVariableName:

spec/jekyll-feed_spec.rb

Lines changed: 80 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -43,53 +43,53 @@
4343
end
4444

4545
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/
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"
4949
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/
50+
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
5151
end
5252

5353
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/
54+
expect(contents).not_to match "http://example.org/images/hubot.png"
55+
expect(contents).not_to match "http://example.org/feeds/atom.xml"
5656
end
5757

5858
it "preserves linebreaks in preformatted text in posts" do
59-
expect(contents).to match %r!Line 1\nLine 2\nLine 3!
59+
expect(contents).to match "Line 1\nLine 2\nLine 3"
6060
end
6161

6262
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>/
63+
expect(contents).to match %r!<author>\s*<name>Ben</name>\s*<email>ben@example\.com</email>\s*<uri>http://ben\.balter\.com</uri>\s*</author>!
6464
end
6565

6666
it "supports post author name as a string" do
67-
expect(contents).to match /<author>\s*<name>Pat<\/name>\s*<\/author>/
67+
expect(contents).to match %r!<author>\s*<name>Pat</name>\s*</author>!
6868
end
6969

7070
it "does not output author tag no author is provided" do
71-
expect(contents).not_to match /<author>\s*<name><\/name>\s*<\/author>/
71+
expect(contents).not_to match %r!<author>\s*<name></name>\s*</author>!
7272
end
7373

7474
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>/
75+
expect(contents).to match %r!<author>\s*<name>Garth</name>\s*<email>example@mail\.com</email>\s*<uri>http://garthdb\.com</uri>\s*</author>!
7676
end
7777

7878
it "converts markdown posts to HTML" do
79-
expect(contents).to match /&lt;p&gt;March the second!&lt;\/p&gt;/
79+
expect(contents).to match %r!&lt;p&gt;March the second\!&lt;/p&gt;!
8080
end
8181

8282
it "uses last_modified_at where available" do
83-
expect(contents).to match /<updated>2015-05-12T13:27:59\+00:00<\/updated>/
83+
expect(contents).to match %r!<updated>2015-05-12T13:27:59\+00:00</updated>!
8484
end
8585

8686
it "replaces newlines in posts to spaces" do
87-
expect(contents).to match %r!<title type="html">The plugin will properly strip newlines.</title>!
87+
expect(contents).to match '<title type="html">The plugin will properly strip newlines.</title>'
8888
end
8989

9090
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\.!
91+
expect(contents).to match "Liquid is rendered."
92+
expect(contents).not_to match "Liquid is not rendered."
9393
end
9494

9595
it "includes the item image" do
@@ -239,9 +239,9 @@
239239
end
240240

241241
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/
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"
245245
end
246246

247247
it "renders the feed meta" do
@@ -258,11 +258,11 @@
258258

259259
context "with a blank site name" do
260260
let(:config) do
261-
Jekyll.configuration({
261+
Jekyll.configuration(
262262
"source" => source_dir,
263263
"destination" => dest_dir,
264-
"url" => "http://example.org",
265-
})
264+
"url" => "http://example.org"
265+
)
266266
end
267267

268268
it "does not output blank title" do
@@ -296,9 +296,9 @@
296296
"feed" => {
297297
"collections" => {
298298
"posts" => {
299-
"path" => "atom.xml"
300-
}
301-
}
299+
"path" => "atom.xml",
300+
},
301+
},
302302
},
303303
}
304304
end
@@ -323,70 +323,70 @@
323323
let(:overrides) { { "lang" => "en-US" } }
324324

325325
it "should set the language" do
326-
expect(contents).to match %r!type="text/html" hreflang="en-US" />!
326+
expect(contents).to match 'type="text/html" hreflang="en-US" />'
327327
end
328328
end
329329

330330
context "with post.lang set" do
331331
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>!
332+
expect(contents).to match '<entry xml:lang="en">'
333+
expect(contents).to match '<entry>'
334334
end
335335
end
336336

337337
context "categories" do
338338
context "with top-level post categories" do
339-
let(:overrides) {
339+
let(:overrides) do
340340
{
341-
"feed" => { "categories" => ["news"] }
341+
"feed" => { "categories" => ["news"] },
342342
}
343-
}
343+
end
344344
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
345345

346346
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/
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"
350350
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/
351+
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
352352
end
353353

354354
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/
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"
359359
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
360360
end
361361
end
362362

363363
context "with collection-level post categories" do
364-
let(:overrides) {
364+
let(:overrides) do
365365
{
366366
"feed" => {
367367
"collections" => {
368368
"posts" => {
369-
"categories" => ["news"]
370-
}
371-
}
372-
}
369+
"categories" => ["news"],
370+
},
371+
},
372+
},
373373
}
374-
}
374+
end
375375
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
376376

377377
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/
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"
381381
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/
382+
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
383383
end
384384

385385
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/
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"
390390
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
391391
end
392392
end
@@ -396,73 +396,72 @@
396396
let(:collection_feed) { File.read(dest_dir("feed/collection.xml")) }
397397

398398
context "when initialized as an array" do
399-
let(:overrides) {
399+
let(:overrides) do
400400
{
401401
"collections" => {
402402
"collection" => {
403-
"output" => true
404-
}
403+
"output" => true,
404+
},
405405
},
406-
"feed" => { "collections" => ["collection"] }
406+
"feed" => { "collections" => ["collection"] },
407407
}
408-
}
409-
408+
end
410409

411410
it "outputs the collection feed" do
412-
expect(collection_feed).to match "<title type=\"html\">My awesome site | Collection</title>"
411+
expect(collection_feed).to match '<title type="html">My awesome site | Collection</title>'
413412
expect(collection_feed).to match "http://example.org/collection/2018-01-01-collection-doc.html"
414413
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/
414+
expect(collection_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
416415
expect(collection_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
417416
end
418417
end
419418

420419
context "with categories" do
421-
let(:overrides) {
420+
let(:overrides) do
422421
{
423422
"collections" => {
424423
"collection" => {
425-
"output" => true
426-
}
424+
"output" => true,
425+
},
427426
},
428-
"feed" => {
427+
"feed" => {
429428
"collections" => {
430429
"collection" => {
431-
"categories" => ["news"]
432-
}
433-
}
434-
}
430+
"categories" => ["news"],
431+
},
432+
},
433+
},
435434
}
436-
}
435+
end
437436
let(:news_feed) { File.read(dest_dir("feed/collection/news.xml")) }
438437

439438
it "outputs the collection category feed" do
440-
expect(news_feed).to match "<title type=\"html\">My awesome site | Collection | News</title>"
439+
expect(news_feed).to match '<title type="html">My awesome site | Collection | News</title>'
441440
expect(news_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
442441
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/
442+
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
444443
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
445444
end
446445
end
447446

448447
context "with a custom path" do
449-
let(:overrides) {
448+
let(:overrides) do
450449
{
451450
"collections" => {
452451
"collection" => {
453-
"output" => true
454-
}
452+
"output" => true,
453+
},
455454
},
456-
"feed" => {
455+
"feed" => {
457456
"collections" => {
458457
"collection" => {
459458
"categories" => ["news"],
460-
"path" => "custom.xml"
461-
}
462-
}
463-
}
459+
"path" => "custom.xml",
460+
},
461+
},
462+
},
464463
}
465-
}
464+
end
466465

467466
it "should write to the custom path" do
468467
expect(Pathname.new(dest_dir("custom.xml"))).to exist

0 commit comments

Comments
 (0)