Skip to content

Commit f056782

Browse files
committed
Enable some rubocop-minitest cops
1 parent acf0399 commit f056782

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

.rubocop.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
require: rubocop-jekyll
1+
require:
2+
- rubocop-jekyll
3+
- rubocop-minitest
24

35
inherit_gem:
46
rubocop-jekyll: .rubocop.yml
57

68
AllCops:
79
TargetRubyVersion: 2.7
10+
SuggestExtensions: false
811

912
Lint/ShadowingOuterLocalVariable:
1013
Exclude:
@@ -24,3 +27,8 @@ Metrics/LineLength:
2427
- lib/jekyll-archives.rb
2528
- lib/jekyll-archives/archive.rb
2629
- test/**/*.rb
30+
31+
Minitest/AssertKindOf:
32+
Enabled: true
33+
Minitest/EmptyLineBeforeAssertionMethods:
34+
Enabled: true

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9"
99
gem "minitest"
1010
gem "rake"
1111
gem "rubocop-jekyll", "~> 0.14.0"
12+
gem "rubocop-minitest"
1213
gem "shoulda-context"

test/test_jekyll_archive.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TestJekyllArchive < Minitest::Test
2727
"url" => "/tag/test-tag/",
2828
"permalink" => nil,
2929
}
30+
3031
assert_equal expected, archive.to_liquid.to_h
3132

3233
archive = @archives.find { |a| a.type == "category" }
@@ -42,6 +43,7 @@ class TestJekyllArchive < Minitest::Test
4243
"url" => "/category/plugins/",
4344
"permalink" => nil,
4445
}
46+
4547
assert_equal expected, archive.to_liquid.to_h
4648

4749
archive = @archives.find { |a| a.type == "year" }
@@ -57,6 +59,7 @@ class TestJekyllArchive < Minitest::Test
5759
"url" => "/2013/",
5860
"permalink" => nil,
5961
}
62+
6063
assert_equal expected, archive.to_liquid.to_h
6164

6265
archive = @archives.find { |a| a.type == "month" }
@@ -72,6 +75,7 @@ class TestJekyllArchive < Minitest::Test
7275
"url" => "/2013/08/",
7376
"permalink" => nil,
7477
}
78+
7579
assert_equal expected, archive.to_liquid.to_h
7680

7781
archive = @archives.find { |a| a.type == "day" }
@@ -87,6 +91,7 @@ class TestJekyllArchive < Minitest::Test
8791
"url" => "/2013/08/16/",
8892
"permalink" => nil,
8993
}
94+
9095
assert_equal expected, archive.to_liquid.to_h
9196
end
9297
end

test/test_jekyll_archives.rb

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,42 @@ class TestJekyllArchives < Minitest::Test
1414

1515
should "generate archive pages by year" do
1616
@archives.generate(@site)
17+
1718
assert archive_exists? @site, "2014/index.html"
1819
assert archive_exists? @site, "2013/index.html"
1920
end
2021

2122
should "generate archive pages by month" do
2223
@archives.generate(@site)
24+
2325
assert archive_exists? @site, "2014/08/index.html"
2426
assert archive_exists? @site, "2014/03/index.html"
2527
end
2628

2729
should "generate archive pages by day" do
2830
@archives.generate(@site)
31+
2932
assert archive_exists? @site, "2014/08/17/index.html"
3033
assert archive_exists? @site, "2013/08/16/index.html"
3134
end
3235

3336
should "generate archive pages by tag" do
3437
@archives.generate(@site)
38+
3539
assert archive_exists? @site, "tag/test-tag/index.html"
3640
assert archive_exists? @site, "tag/tagged/index.html"
3741
assert archive_exists? @site, "tag/new/index.html"
3842
end
3943

4044
should "generate archive pages by category" do
4145
@archives.generate(@site)
46+
4247
assert archive_exists? @site, "category/plugins/index.html"
4348
end
4449

4550
should "generate archive pages with a layout" do
4651
@site.process
52+
4753
assert_equal "Test", read_file("tag/test-tag/index.html")
4854
end
4955
end
@@ -62,6 +68,7 @@ class TestJekyllArchives < Minitest::Test
6268

6369
should "generate slugs using the mode specified" do
6470
@archives.generate(@site)
71+
6572
assert archive_exists? @site, "category/💎/index.html"
6673
end
6774
end
@@ -77,6 +84,7 @@ class TestJekyllArchives < Minitest::Test
7784

7885
should "use custom layout" do
7986
@site.process
87+
8088
assert_equal "Test too", read_file("tag/test-tag/index.html")
8189
end
8290
end
@@ -164,10 +172,10 @@ class TestJekyllArchives < Minitest::Test
164172
end
165173

166174
should "not generate the disabled archives" do
167-
assert !archive_exists?(@site, "2014/index.html")
168-
assert !archive_exists?(@site, "2014/08/index.html")
169-
assert !archive_exists?(@site, "2013/08/16/index.html")
170-
assert !archive_exists?(@site, "category/plugins/index.html")
175+
refute archive_exists?(@site, "2014/index.html")
176+
refute archive_exists?(@site, "2014/08/index.html")
177+
refute archive_exists?(@site, "2013/08/16/index.html")
178+
refute archive_exists?(@site, "category/plugins/index.html")
171179
end
172180
end
173181

@@ -186,25 +194,25 @@ class TestJekyllArchives < Minitest::Test
186194
end
187195

188196
should "populate the title field in case of category or tag" do
189-
assert @tag_archive.title.is_a? String
190-
assert @category_archive.title.is_a? String
197+
assert_kind_of String, @tag_archive.title
198+
assert_kind_of String, @category_archive.title
191199
end
192200

193201
should "use nil for the title field in case of dates" do
194-
assert @year_archive.title.nil?
195-
assert @month_archive.title.nil?
196-
assert @day_archive.title.nil?
202+
assert_nil @year_archive.title
203+
assert_nil @month_archive.title
204+
assert_nil @day_archive.title
197205
end
198206

199207
should "use nil for the date field in case of category or tag" do
200-
assert @tag_archive.date.nil?
201-
assert @category_archive.date.nil?
208+
assert_nil @tag_archive.date
209+
assert_nil @category_archive.date
202210
end
203211

204212
should "populate the date field with a Date in case of dates" do
205-
assert @year_archive.date.is_a? Date
206-
assert @month_archive.date.is_a? Date
207-
assert @day_archive.date.is_a? Date
213+
assert_kind_of Date, @year_archive.date
214+
assert_kind_of Date, @month_archive.date
215+
assert_kind_of Date, @day_archive.date
208216
end
209217
end
210218

@@ -215,6 +223,7 @@ class TestJekyllArchives < Minitest::Test
215223
site.read
216224
site.generate
217225
end
226+
218227
assert_includes output, "Archives: Expected a hash but got [\"apples\", \"oranges\"]"
219228
assert_includes output, "Archives will not be generated for this site."
220229

@@ -223,6 +232,7 @@ class TestJekyllArchives < Minitest::Test
223232
site.read
224233
site.generate
225234
end
235+
226236
assert_includes output, "Archives: Expected a hash but got nil"
227237
assert_includes output, "Archives will not be generated for this site."
228238
end
@@ -232,6 +242,7 @@ class TestJekyllArchives < Minitest::Test
232242
site = fixture_site("jekyll-archives" => nil)
233243
site.read
234244
site.generate
245+
235246
assert_nil(site.pages.find { |p| p.is_a?(Jekyll::Archives::Archive) })
236247
end
237248
end
@@ -242,6 +253,7 @@ class TestJekyllArchives < Minitest::Test
242253
@site.read
243254
@site.generate
244255
end
256+
245257
refute_includes output, "Archives: Expected a hash but got nil"
246258
assert_nil(@site.pages.find { |p| p.is_a?(Jekyll::Archives::Archive) })
247259
end

0 commit comments

Comments
 (0)