html-proofer 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/bin/htmlproof +3 -1
- data/html-proofer.gemspec +4 -2
- data/lib/html/proofer.rb +66 -10
- data/lib/html/proofer/check.rb +1 -1
- data/lib/html/proofer/checkable.rb +6 -6
- data/lib/html/proofer/checks.rb +2 -1
- data/lib/html/proofer/checks/favicon.rb +0 -2
- data/lib/html/proofer/checks/html.rb +24 -0
- data/lib/html/proofer/checks/links.rb +12 -0
- data/lib/html/proofer/issue.rb +1 -1
- data/lib/html/proofer/version.rb +5 -0
- data/spec/html/proofer/favicon_spec.rb +15 -14
- data/spec/html/proofer/fixtures/html/div_inside_head.html +6 -0
- data/spec/html/proofer/fixtures/html/html5_tags.html +9 -0
- data/spec/html/proofer/fixtures/html/invalid_tag.html +3 -0
- data/spec/html/proofer/fixtures/html/missing_closing_quotes.html +5 -0
- data/spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html +7 -0
- data/spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html +4 -0
- data/spec/html/proofer/fixtures/html/unmatched_end_tag.html +5 -0
- data/spec/html/proofer/fixtures/links/brokenHashOnTheWeb.html +2 -0
- data/spec/html/proofer/fixtures/links/githubHash.html +1 -0
- data/spec/html/proofer/fixtures/links/non_standard_characters.html +10 -0
- data/spec/html/proofer/fixtures/links/other_protocols.html +4 -0
- data/spec/html/proofer/fixtures/sorting/issue/broken_image_one.html +1 -0
- data/spec/html/proofer/fixtures/sorting/issue/broken_image_two.html +4 -0
- data/spec/html/proofer/fixtures/sorting/path/multiple_issues.html +11 -0
- data/spec/html/proofer/fixtures/sorting/path/single_issue.html +1 -0
- data/spec/html/proofer/fixtures/sorting/status/a_404.html +1 -0
- data/spec/html/proofer/fixtures/sorting/status/broken_link.html +3 -0
- data/spec/html/proofer/fixtures/sorting/status/missing_redirect.html +1 -0
- data/spec/html/proofer/html_spec.rb +51 -0
- data/spec/html/proofer/images_spec.rb +33 -33
- data/spec/html/proofer/links_spec.rb +115 -86
- data/spec/html/proofer/scripts_spec.rb +12 -12
- data/spec/html/proofer_spec.rb +50 -9
- data/spec/spec_helper.rb +13 -1
- metadata +58 -4
@@ -4,38 +4,38 @@ describe "Scripts test" do
|
|
4
4
|
|
5
5
|
it "fails for broken external src" do
|
6
6
|
file = "#{FIXTURES_DIR}/scripts/script_broken_external.html"
|
7
|
-
|
8
|
-
|
7
|
+
proofer = make_proofer(file)
|
8
|
+
expect(proofer.failed_tests.first).to match /External link http:\/\/www.asdo3IRJ395295jsingrkrg4.com\/asdo3IRJ.js? failed: 0 Couldn't resolve host name/
|
9
9
|
end
|
10
10
|
|
11
11
|
it "works for valid internal src" do
|
12
12
|
file = "#{FIXTURES_DIR}/scripts/script_valid_internal.html"
|
13
|
-
|
14
|
-
|
13
|
+
proofer = make_proofer(file)
|
14
|
+
expect(proofer.failed_tests).to eq []
|
15
15
|
end
|
16
16
|
|
17
17
|
it "fails for missing internal src" do
|
18
18
|
file = "#{FIXTURES_DIR}/scripts/script_missing_internal.html"
|
19
|
-
|
20
|
-
|
19
|
+
proofer = make_proofer(file)
|
20
|
+
expect(proofer.failed_tests.first).to match /doesnotexist.js does not exist/
|
21
21
|
end
|
22
22
|
|
23
23
|
it "works for present content" do
|
24
24
|
file = "#{FIXTURES_DIR}/scripts/script_content.html"
|
25
|
-
|
26
|
-
|
25
|
+
proofer = make_proofer(file)
|
26
|
+
expect(proofer.failed_tests).to eq []
|
27
27
|
end
|
28
28
|
|
29
29
|
it "fails for absent content" do
|
30
30
|
file = "#{FIXTURES_DIR}/scripts/script_content_absent.html"
|
31
|
-
|
32
|
-
|
31
|
+
proofer = make_proofer(file)
|
32
|
+
expect(proofer.failed_tests.first).to match /script is empty and has no src attribute/
|
33
33
|
end
|
34
34
|
|
35
35
|
it "works for broken script within pre" do
|
36
36
|
script_pre = "#{FIXTURES_DIR}/scripts/script_in_pre.html"
|
37
|
-
|
38
|
-
|
37
|
+
proofer = make_proofer(script_pre)
|
38
|
+
expect(proofer.failed_tests).to eq []
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
data/spec/html/proofer_spec.rb
CHANGED
@@ -5,9 +5,8 @@ describe HTML::Proofer do
|
|
5
5
|
describe "#failed_tests" do
|
6
6
|
it "is a list of the formatted errors" do
|
7
7
|
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
|
8
|
-
proofer =
|
9
|
-
|
10
|
-
proofer.failed_tests.should eq(["\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./notreal.html, which does not exist", "\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./missingImageAlt.html, which does not exist"])
|
8
|
+
proofer = make_proofer(brokenLinkInternalFilepath)
|
9
|
+
expect(proofer.failed_tests).to eq(["\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./notreal.html, which does not exist", "\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./missingImageAlt.html, which does not exist"])
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
@@ -15,7 +14,7 @@ describe HTML::Proofer do
|
|
15
14
|
it "works for directory that ends with .html" do
|
16
15
|
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
17
16
|
proofer = HTML::Proofer.new folder
|
18
|
-
proofer.files.
|
17
|
+
expect(proofer.files).to eq(["#{folder}/index.html"])
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -23,16 +22,58 @@ describe HTML::Proofer do
|
|
23
22
|
it "strips out undesired Typhoeus options" do
|
24
23
|
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
25
24
|
proofer = HTML::Proofer.new folder, :verbose => true
|
26
|
-
proofer.options[:verbose].
|
27
|
-
proofer.typhoeus_opts[:verbose].
|
25
|
+
expect(proofer.options[:verbose]).to eq(true)
|
26
|
+
expect(proofer.typhoeus_opts[:verbose]).to eq(nil)
|
28
27
|
end
|
29
28
|
|
30
29
|
it "takes options for Parallel" do
|
31
30
|
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
32
31
|
proofer = HTML::Proofer.new folder, :parallel => { :in_processes => 3 }
|
33
|
-
proofer.parallel_opts[:in_processes].
|
34
|
-
proofer.typhoeus_opts[:in_processes].
|
35
|
-
proofer.options[:parallel].
|
32
|
+
expect(proofer.parallel_opts[:in_processes]).to eq(3)
|
33
|
+
expect(proofer.typhoeus_opts[:in_processes]).to eq(nil)
|
34
|
+
expect(proofer.options[:parallel]).to eq(nil)
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "sorting" do
|
38
|
+
# would love to know why Travis barfs here
|
39
|
+
it "understands sorting by path", :skip => ENV['TRAVIS'] do
|
40
|
+
output = send_proofer_output("#{FIXTURES_DIR}/sorting/path")
|
41
|
+
|
42
|
+
expect(output.strip).to eq("""
|
43
|
+
- spec/html/proofer/fixtures/sorting/path/multiple_issues.html
|
44
|
+
* tel: contains no phone number
|
45
|
+
* internal image gpl.png does not exist
|
46
|
+
* image gpl.png does not have an alt attribute
|
47
|
+
- spec/html/proofer/fixtures/sorting/path/single_issue.html
|
48
|
+
* image has a terrible filename (./Screen Shot 2012-08-09 at 7.51.18 AM.png)
|
49
|
+
""".strip)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "understands sorting by issue" do
|
53
|
+
output = send_proofer_output("#{FIXTURES_DIR}/sorting/issue", :error_sort => :desc)
|
54
|
+
expect(output.strip).to eq("""
|
55
|
+
- image ./gpl.png does not have an alt attribute
|
56
|
+
* spec/html/proofer/fixtures/sorting/issue/broken_image_one.html
|
57
|
+
* spec/html/proofer/fixtures/sorting/issue/broken_image_two.html
|
58
|
+
- internal image ./gpl.png does not exist
|
59
|
+
* spec/html/proofer/fixtures/sorting/issue/broken_image_one.html
|
60
|
+
* spec/html/proofer/fixtures/sorting/issue/broken_image_two.html
|
61
|
+
- internal image NOT_AN_IMAGE does not exist
|
62
|
+
* spec/html/proofer/fixtures/sorting/issue/broken_image_two.html
|
63
|
+
""".strip)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
it "understands sorting by status" do
|
68
|
+
output = send_proofer_output("#{FIXTURES_DIR}/sorting/status", :followlocation => false, :error_sort => :status)
|
69
|
+
expect(output.strip).to eq("""
|
70
|
+
- -1
|
71
|
+
* spec/html/proofer/fixtures/sorting/status/broken_link.html: internally linking to nowhere.fooof, which does not exist
|
72
|
+
- 404
|
73
|
+
* spec/html/proofer/fixtures/sorting/status/a_404.html: External link http://upload.wikimedia.org/wikipedia/en/thumb/not_here.png failed: 404 No error
|
74
|
+
* spec/html/proofer/fixtures/sorting/status/broken_link.html: External link http://upload.wikimedia.org/wikipedia/en/thumb/fooooof.png failed: 404 No error
|
75
|
+
""".strip)
|
76
|
+
end
|
36
77
|
end
|
37
78
|
end
|
38
79
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ FIXTURES_DIR = "spec/html/proofer/fixtures"
|
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
7
|
# Use color in STDOUT
|
8
|
-
config.
|
8
|
+
config.color = true
|
9
9
|
|
10
10
|
# Use color not only in STDOUT but also in pagers and files
|
11
11
|
config.tty = true
|
@@ -31,3 +31,15 @@ def capture_stderr(&block)
|
|
31
31
|
end
|
32
32
|
fake_err.string
|
33
33
|
end
|
34
|
+
|
35
|
+
def make_proofer(file, opts={})
|
36
|
+
proofer = HTML::Proofer.new(file, opts)
|
37
|
+
capture_stderr { proofer.run }
|
38
|
+
# proofer.run # when I want to see output
|
39
|
+
proofer
|
40
|
+
end
|
41
|
+
|
42
|
+
def send_proofer_output(file, opts={})
|
43
|
+
proofer = HTML::Proofer.new(file, opts)
|
44
|
+
capture_stderr { proofer.run }
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: addressable
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.3'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.3'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: redcarpet
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +128,14 @@ dependencies:
|
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
131
|
+
version: 3.1.0
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: 3.1.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rake
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,10 +185,12 @@ files:
|
|
171
185
|
- lib/html/proofer/checkable.rb
|
172
186
|
- lib/html/proofer/checks.rb
|
173
187
|
- lib/html/proofer/checks/favicon.rb
|
188
|
+
- lib/html/proofer/checks/html.rb
|
174
189
|
- lib/html/proofer/checks/images.rb
|
175
190
|
- lib/html/proofer/checks/links.rb
|
176
191
|
- lib/html/proofer/checks/scripts.rb
|
177
192
|
- lib/html/proofer/issue.rb
|
193
|
+
- lib/html/proofer/version.rb
|
178
194
|
- spec/html/proofer/favicon_spec.rb
|
179
195
|
- spec/html/proofer/fixtures/favicon/favicon_absent.html
|
180
196
|
- spec/html/proofer/fixtures/favicon/favicon_absent_apple.html
|
@@ -182,6 +198,13 @@ files:
|
|
182
198
|
- spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html
|
183
199
|
- spec/html/proofer/fixtures/favicon/favicon_present.html
|
184
200
|
- spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html
|
201
|
+
- spec/html/proofer/fixtures/html/div_inside_head.html
|
202
|
+
- spec/html/proofer/fixtures/html/html5_tags.html
|
203
|
+
- spec/html/proofer/fixtures/html/invalid_tag.html
|
204
|
+
- spec/html/proofer/fixtures/html/missing_closing_quotes.html
|
205
|
+
- spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html
|
206
|
+
- spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html
|
207
|
+
- spec/html/proofer/fixtures/html/unmatched_end_tag.html
|
185
208
|
- spec/html/proofer/fixtures/images/existingImageExternal.html
|
186
209
|
- spec/html/proofer/fixtures/images/gpl.png
|
187
210
|
- spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
|
@@ -204,6 +227,7 @@ files:
|
|
204
227
|
- spec/html/proofer/fixtures/links/blank_tel_link.html
|
205
228
|
- spec/html/proofer/fixtures/links/brokenHashExternal.html
|
206
229
|
- spec/html/proofer/fixtures/links/brokenHashInternal.html
|
230
|
+
- spec/html/proofer/fixtures/links/brokenHashOnTheWeb.html
|
207
231
|
- spec/html/proofer/fixtures/links/brokenInternalLink.html
|
208
232
|
- spec/html/proofer/fixtures/links/brokenLinkExternal.html
|
209
233
|
- spec/html/proofer/fixtures/links/brokenLinkInternal.html
|
@@ -217,6 +241,7 @@ files:
|
|
217
241
|
- spec/html/proofer/fixtures/links/folder/assets/barrel.png
|
218
242
|
- spec/html/proofer/fixtures/links/folder/index.html
|
219
243
|
- spec/html/proofer/fixtures/links/folder/relativeImage.html
|
244
|
+
- spec/html/proofer/fixtures/links/githubHash.html
|
220
245
|
- spec/html/proofer/fixtures/links/gpl.png
|
221
246
|
- spec/html/proofer/fixtures/links/hashReferringToSelf.html
|
222
247
|
- spec/html/proofer/fixtures/links/head_link_href.html
|
@@ -237,7 +262,9 @@ files:
|
|
237
262
|
- spec/html/proofer/fixtures/links/mailto_link.html
|
238
263
|
- spec/html/proofer/fixtures/links/missingLinkHref.html
|
239
264
|
- spec/html/proofer/fixtures/links/multipleProblems.html
|
265
|
+
- spec/html/proofer/fixtures/links/non_standard_characters.html
|
240
266
|
- spec/html/proofer/fixtures/links/notarealhash.html
|
267
|
+
- spec/html/proofer/fixtures/links/other_protocols.html
|
241
268
|
- spec/html/proofer/fixtures/links/placeholder_with_empty_id.html
|
242
269
|
- spec/html/proofer/fixtures/links/placeholder_with_id.html
|
243
270
|
- spec/html/proofer/fixtures/links/placeholder_with_name.html
|
@@ -259,6 +286,14 @@ files:
|
|
259
286
|
- spec/html/proofer/fixtures/scripts/script_in_pre.html
|
260
287
|
- spec/html/proofer/fixtures/scripts/script_missing_internal.html
|
261
288
|
- spec/html/proofer/fixtures/scripts/script_valid_internal.html
|
289
|
+
- spec/html/proofer/fixtures/sorting/issue/broken_image_one.html
|
290
|
+
- spec/html/proofer/fixtures/sorting/issue/broken_image_two.html
|
291
|
+
- spec/html/proofer/fixtures/sorting/path/multiple_issues.html
|
292
|
+
- spec/html/proofer/fixtures/sorting/path/single_issue.html
|
293
|
+
- spec/html/proofer/fixtures/sorting/status/a_404.html
|
294
|
+
- spec/html/proofer/fixtures/sorting/status/broken_link.html
|
295
|
+
- spec/html/proofer/fixtures/sorting/status/missing_redirect.html
|
296
|
+
- spec/html/proofer/html_spec.rb
|
262
297
|
- spec/html/proofer/images_spec.rb
|
263
298
|
- spec/html/proofer/links_spec.rb
|
264
299
|
- spec/html/proofer/scripts_spec.rb
|
@@ -298,6 +333,13 @@ test_files:
|
|
298
333
|
- spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html
|
299
334
|
- spec/html/proofer/fixtures/favicon/favicon_present.html
|
300
335
|
- spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html
|
336
|
+
- spec/html/proofer/fixtures/html/div_inside_head.html
|
337
|
+
- spec/html/proofer/fixtures/html/html5_tags.html
|
338
|
+
- spec/html/proofer/fixtures/html/invalid_tag.html
|
339
|
+
- spec/html/proofer/fixtures/html/missing_closing_quotes.html
|
340
|
+
- spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html
|
341
|
+
- spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html
|
342
|
+
- spec/html/proofer/fixtures/html/unmatched_end_tag.html
|
301
343
|
- spec/html/proofer/fixtures/images/existingImageExternal.html
|
302
344
|
- spec/html/proofer/fixtures/images/gpl.png
|
303
345
|
- spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
|
@@ -320,6 +362,7 @@ test_files:
|
|
320
362
|
- spec/html/proofer/fixtures/links/blank_tel_link.html
|
321
363
|
- spec/html/proofer/fixtures/links/brokenHashExternal.html
|
322
364
|
- spec/html/proofer/fixtures/links/brokenHashInternal.html
|
365
|
+
- spec/html/proofer/fixtures/links/brokenHashOnTheWeb.html
|
323
366
|
- spec/html/proofer/fixtures/links/brokenInternalLink.html
|
324
367
|
- spec/html/proofer/fixtures/links/brokenLinkExternal.html
|
325
368
|
- spec/html/proofer/fixtures/links/brokenLinkInternal.html
|
@@ -333,6 +376,7 @@ test_files:
|
|
333
376
|
- spec/html/proofer/fixtures/links/folder/assets/barrel.png
|
334
377
|
- spec/html/proofer/fixtures/links/folder/index.html
|
335
378
|
- spec/html/proofer/fixtures/links/folder/relativeImage.html
|
379
|
+
- spec/html/proofer/fixtures/links/githubHash.html
|
336
380
|
- spec/html/proofer/fixtures/links/gpl.png
|
337
381
|
- spec/html/proofer/fixtures/links/hashReferringToSelf.html
|
338
382
|
- spec/html/proofer/fixtures/links/head_link_href.html
|
@@ -353,7 +397,9 @@ test_files:
|
|
353
397
|
- spec/html/proofer/fixtures/links/mailto_link.html
|
354
398
|
- spec/html/proofer/fixtures/links/missingLinkHref.html
|
355
399
|
- spec/html/proofer/fixtures/links/multipleProblems.html
|
400
|
+
- spec/html/proofer/fixtures/links/non_standard_characters.html
|
356
401
|
- spec/html/proofer/fixtures/links/notarealhash.html
|
402
|
+
- spec/html/proofer/fixtures/links/other_protocols.html
|
357
403
|
- spec/html/proofer/fixtures/links/placeholder_with_empty_id.html
|
358
404
|
- spec/html/proofer/fixtures/links/placeholder_with_id.html
|
359
405
|
- spec/html/proofer/fixtures/links/placeholder_with_name.html
|
@@ -375,6 +421,14 @@ test_files:
|
|
375
421
|
- spec/html/proofer/fixtures/scripts/script_in_pre.html
|
376
422
|
- spec/html/proofer/fixtures/scripts/script_missing_internal.html
|
377
423
|
- spec/html/proofer/fixtures/scripts/script_valid_internal.html
|
424
|
+
- spec/html/proofer/fixtures/sorting/issue/broken_image_one.html
|
425
|
+
- spec/html/proofer/fixtures/sorting/issue/broken_image_two.html
|
426
|
+
- spec/html/proofer/fixtures/sorting/path/multiple_issues.html
|
427
|
+
- spec/html/proofer/fixtures/sorting/path/single_issue.html
|
428
|
+
- spec/html/proofer/fixtures/sorting/status/a_404.html
|
429
|
+
- spec/html/proofer/fixtures/sorting/status/broken_link.html
|
430
|
+
- spec/html/proofer/fixtures/sorting/status/missing_redirect.html
|
431
|
+
- spec/html/proofer/html_spec.rb
|
378
432
|
- spec/html/proofer/images_spec.rb
|
379
433
|
- spec/html/proofer/links_spec.rb
|
380
434
|
- spec/html/proofer/scripts_spec.rb
|