html-proofer 1.6.0 → 2.0.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +74 -56
- data/Rakefile +4 -6
- data/bin/htmlproof +46 -36
- data/html-proofer.gemspec +22 -22
- data/lib/html/proofer/check_runner/issue.rb +62 -0
- data/lib/html/proofer/{check.rb → check_runner.rb} +11 -19
- data/lib/html/proofer/checkable.rb +42 -28
- data/lib/html/proofer/checks/favicon.rb +6 -6
- data/lib/html/proofer/checks/html.rb +11 -12
- data/lib/html/proofer/checks/images.rb +11 -11
- data/lib/html/proofer/checks/links.rb +30 -28
- data/lib/html/proofer/checks/scripts.rb +7 -8
- data/lib/html/proofer/log.rb +38 -0
- data/lib/html/proofer/url_validator.rb +135 -0
- data/lib/html/proofer/utils.rb +24 -0
- data/lib/html/proofer/version.rb +1 -1
- data/lib/html/proofer.rb +95 -199
- data/spec/html/proofer/command_spec.rb +82 -0
- data/spec/html/proofer/favicon_spec.rb +20 -20
- data/spec/html/proofer/fixtures/images/srcSetCheck.html +7 -0
- data/spec/html/proofer/fixtures/images/srcSetIgnorable.html +13 -0
- data/spec/html/proofer/fixtures/images/srcSetMissingAlt.html +7 -0
- data/spec/html/proofer/fixtures/images/srcSetMissingImage.html +7 -0
- data/spec/html/proofer/fixtures/links/erstiebegru/314/210/303/237ung.html +1 -0
- data/spec/html/proofer/fixtures/links/erstiebegr/303/274/303/237ung.html +1 -0
- data/spec/html/proofer/fixtures/links/file.foo +11 -0
- data/spec/html/proofer/fixtures/links/folder/multiples/catalog/file.html +8 -0
- data/spec/html/proofer/fixtures/links/folder/multiples/javadoc/file.html +8 -0
- data/spec/html/proofer/fixtures/links/nodupe.html +1 -1
- data/spec/html/proofer/fixtures/links/redirected_error.html +1 -0
- data/spec/html/proofer/fixtures/links/rootLink/rootLink.html +0 -1
- data/spec/html/proofer/fixtures/links/urlencoded-href.html +2 -0
- data/spec/html/proofer/fixtures/links/utf8Link.html +2 -0
- data/spec/html/proofer/fixtures/utils/lang-jp.html +1 -0
- data/spec/html/proofer/html_spec.rb +25 -25
- data/spec/html/proofer/images_spec.rb +59 -35
- data/spec/html/proofer/links_spec.rb +152 -109
- data/spec/html/proofer/scripts_spec.rb +17 -17
- data/spec/html/proofer/utils_spec.rb +14 -0
- data/spec/html/proofer_spec.rb +58 -38
- data/spec/spec_helper.rb +13 -6
- metadata +39 -7
- data/lib/html/proofer/checks.rb +0 -15
- data/lib/html/proofer/issue.rb +0 -21
@@ -1,51 +1,51 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
3
|
+
describe 'Html test' do
|
4
|
+
it 'ignores an invalid tag by default' do
|
5
5
|
html = "#{FIXTURES_DIR}/html/invalid_tag.html"
|
6
|
-
|
7
|
-
expect(
|
6
|
+
proofer = run_proofer(html)
|
7
|
+
expect(proofer.failed_tests).to eq []
|
8
8
|
end
|
9
9
|
|
10
10
|
it "doesn't fail for html5 tags" do
|
11
11
|
html = "#{FIXTURES_DIR}/html/html5_tags.html"
|
12
|
-
|
13
|
-
expect(
|
12
|
+
proofer = run_proofer(html, { :check_html => true })
|
13
|
+
expect(proofer.failed_tests).to eq []
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'fails for an invalid tag' do
|
17
17
|
html = "#{FIXTURES_DIR}/html/invalid_tag.html"
|
18
|
-
|
19
|
-
expect(
|
18
|
+
proofer = run_proofer(html, { :check_html => true })
|
19
|
+
expect(proofer.failed_tests.first).to match(/Tag myfancytag invalid/)
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'fails for an unmatched end tag' do
|
23
23
|
html = "#{FIXTURES_DIR}/html/unmatched_end_tag.html"
|
24
|
-
|
25
|
-
expect(
|
24
|
+
proofer = run_proofer(html, { :check_html => true })
|
25
|
+
expect(proofer.failed_tests.first).to match(/Unexpected end tag : div/)
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'fails for an unescaped ampersand in attribute' do
|
29
29
|
html = "#{FIXTURES_DIR}/html/unescaped_ampersand_in_attribute.html"
|
30
|
-
|
31
|
-
expect(
|
30
|
+
proofer = run_proofer(html, { :check_html => true })
|
31
|
+
expect(proofer.failed_tests.first).to match(/htmlParseEntityRef: expecting ';'/)
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'fails for mismatch between opening and ending tag' do
|
35
35
|
html = "#{FIXTURES_DIR}/html/opening_and_ending_tag_mismatch.html"
|
36
|
-
|
37
|
-
expect(
|
36
|
+
proofer = run_proofer(html, { :check_html => true })
|
37
|
+
expect(proofer.failed_tests.first).to match(/Opening and ending tag mismatch: p and strong/)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'fails for div inside head' do
|
41
41
|
html = "#{FIXTURES_DIR}/html/div_inside_head.html"
|
42
|
-
|
43
|
-
expect(
|
42
|
+
proofer = run_proofer(html, { :check_html => true })
|
43
|
+
expect(proofer.failed_tests.first).to match(/Unexpected end tag : head/)
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
46
|
+
it 'fails for missing closing quotation mark in href' do
|
47
47
|
html = "#{FIXTURES_DIR}/html/missing_closing_quotes.html"
|
48
|
-
|
49
|
-
expect(
|
48
|
+
proofer = run_proofer(html, { :check_html => true })
|
49
|
+
expect(proofer.failed_tests.to_s).to match(/Couldn't find end of Start Tag a/)
|
50
50
|
end
|
51
51
|
end
|
@@ -1,98 +1,122 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
3
|
+
describe 'Images test' do
|
4
|
+
it 'passes for existing external images' do
|
5
5
|
externalImageFilepath = "#{FIXTURES_DIR}/images/existingImageExternal.html"
|
6
|
-
proofer =
|
6
|
+
proofer = run_proofer(externalImageFilepath)
|
7
7
|
expect(proofer.failed_tests).to eq []
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'fails for image without alt attribute' do
|
11
11
|
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
|
12
|
-
proofer =
|
13
|
-
expect(proofer.failed_tests.first).to match
|
12
|
+
proofer = run_proofer(missingAltFilepath)
|
13
|
+
expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'fails for image with an empty alt attribute' do
|
17
17
|
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAltText.html"
|
18
|
-
proofer =
|
19
|
-
expect(proofer.failed_tests.first).to match
|
18
|
+
proofer = run_proofer(missingAltFilepath)
|
19
|
+
expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'fails for missing external images' do
|
23
23
|
externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
|
24
|
-
proofer =
|
25
|
-
expect(proofer.failed_tests.first).to match
|
24
|
+
proofer = run_proofer(externalImageFilepath)
|
25
|
+
expect(proofer.failed_tests.first).to match(/failed: 0 Couldn't resolve host/)
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'fails for missing internal images' do
|
29
29
|
internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
|
30
|
-
proofer =
|
31
|
-
expect(proofer.failed_tests.first).to match
|
30
|
+
proofer = run_proofer(internalImageFilepath)
|
31
|
+
expect(proofer.failed_tests.first).to match(/doesnotexist.png does not exist/)
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'fails for image with no src' do
|
35
35
|
imageSrcFilepath = "#{FIXTURES_DIR}/images/missingImageSrc.html"
|
36
|
-
proofer =
|
37
|
-
expect(proofer.failed_tests.first).to match
|
36
|
+
proofer = run_proofer(imageSrcFilepath)
|
37
|
+
expect(proofer.failed_tests.first).to match(/image has no src or srcset attribute/)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'fails for image with default mac filename' do
|
41
41
|
terribleImageName = "#{FIXTURES_DIR}/images/terribleImageName.html"
|
42
|
-
proofer =
|
43
|
-
expect(proofer.failed_tests.first).to match
|
42
|
+
proofer = run_proofer(terribleImageName)
|
43
|
+
expect(proofer.failed_tests.first).to match(/image has a terrible filename/)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'ignores images marked as ignore data-proofer-ignore' do
|
47
47
|
ignorableImages = "#{FIXTURES_DIR}/images/ignorableImages.html"
|
48
|
-
proofer =
|
48
|
+
proofer = run_proofer(ignorableImages)
|
49
49
|
expect(proofer.failed_tests).to eq []
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'properly checks relative images' do
|
53
53
|
relativeImages = "#{FIXTURES_DIR}/images/rootRelativeImages.html"
|
54
|
-
proofer =
|
54
|
+
proofer = run_proofer(relativeImages)
|
55
55
|
expect(proofer.failed_tests).to eq []
|
56
56
|
|
57
57
|
relativeImages = "#{FIXTURES_DIR}/resources/books/nestedRelativeImages.html"
|
58
|
-
proofer =
|
58
|
+
proofer = run_proofer(relativeImages)
|
59
59
|
expect(proofer.failed_tests).to eq []
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'properly ignores data URI images' do
|
63
63
|
dataURIImage = "#{FIXTURES_DIR}/images/workingDataURIImage.html"
|
64
|
-
proofer =
|
64
|
+
proofer = run_proofer(dataURIImage)
|
65
65
|
expect(proofer.failed_tests).to eq []
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
68
|
+
it 'works for valid images missing the protocol' do
|
69
69
|
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
|
70
|
-
proofer =
|
70
|
+
proofer = run_proofer(missingProtocolLink)
|
71
71
|
expect(proofer.failed_tests).to eq []
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'fails for invalid images missing the protocol' do
|
75
75
|
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
|
76
|
-
proofer =
|
77
|
-
expect(proofer.failed_tests.first).to match
|
76
|
+
proofer = run_proofer(missingProtocolLink)
|
77
|
+
expect(proofer.failed_tests.first).to match(/404 No error/)
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'properly checks relative links' do
|
81
81
|
relativeLinks = "#{FIXTURES_DIR}/images/relativeToSelf.html"
|
82
|
-
proofer =
|
82
|
+
proofer = run_proofer(relativeLinks)
|
83
83
|
expect(proofer.failed_tests).to eq []
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'properly ignores missing alt tags when asked' do
|
87
87
|
ignorableLinks = "#{FIXTURES_DIR}/images/ignorableAltViaOptions.html"
|
88
|
-
proofer =
|
88
|
+
proofer = run_proofer(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]})
|
89
89
|
expect(proofer.failed_tests).to eq []
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'properly ignores missing alt tags, but not all URLs, when asked' do
|
93
93
|
ignorableLinks = "#{FIXTURES_DIR}/images/ignoreAltButNotLink.html"
|
94
|
-
proofer =
|
95
|
-
expect(proofer.failed_tests.first).to match
|
94
|
+
proofer = run_proofer(ignorableLinks, {:alt_ignore => [/.*/]})
|
95
|
+
expect(proofer.failed_tests.first).to match(/Couldn't resolve host name/)
|
96
96
|
expect(proofer.failed_tests.first).to_not match /does not have an alt attribute/
|
97
97
|
end
|
98
|
+
|
99
|
+
it 'works for images with a srcset' do
|
100
|
+
srcSetCheck = "#{FIXTURES_DIR}/images/srcSetCheck.html"
|
101
|
+
proofer = run_proofer(srcSetCheck)
|
102
|
+
expect(proofer.failed_tests).to eq []
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'fails for images with a srcset but missing alt' do
|
106
|
+
srcSetMissingAlt = "#{FIXTURES_DIR}/images/srcSetMissingAlt.html"
|
107
|
+
proofer = run_proofer(srcSetMissingAlt)
|
108
|
+
expect(proofer.failed_tests.first).to match(/image gpl.png does not have an alt attribute/)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'fails for images with an alt but missing src or srcset' do
|
112
|
+
srcSetMissingAlt = "#{FIXTURES_DIR}/images/srcSetMissingImage.html"
|
113
|
+
proofer = run_proofer(srcSetMissingAlt)
|
114
|
+
expect(proofer.failed_tests.first).to match(/internal image notreal.png does not exist/)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'properly ignores missing alt tags when asked for srcset' do
|
118
|
+
ignorableLinks = "#{FIXTURES_DIR}/images/srcSetIgnorable.html"
|
119
|
+
proofer = run_proofer(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]})
|
120
|
+
expect(proofer.failed_tests).to eq []
|
121
|
+
end
|
98
122
|
end
|