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
@@ -0,0 +1 @@
|
|
1
|
+
<a href="https://github.com/typhoeus/typhoeus#other-curl-options">This gets converted</a>.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<html>
|
2
|
+
|
3
|
+
<body>
|
4
|
+
|
5
|
+
<a href="http://ben.balter.com/2014/10/08/why-government-contractors-should-%3C3-open-source/">We <3 valid links</a>
|
6
|
+
<a href="http://ben.balter.com/2014/09/29/source-disclosed-%E2%89%A0-open-source/">A valid URL</a>
|
7
|
+
|
8
|
+
</body>
|
9
|
+
|
10
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<img src="./gpl.png" />
|
@@ -0,0 +1 @@
|
|
1
|
+
<img src="./Screen Shot 2012-08-09 at 7.51.18 AM.png" alt="textbox"/>
|
@@ -0,0 +1 @@
|
|
1
|
+
<img alt="An existing image" src="//upload.wikimedia.org/wikipedia/en/thumb/not_here.png" />
|
@@ -0,0 +1 @@
|
|
1
|
+
<a href="https://help.github.com/changing-author-info/">This is another redirect.</a>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Html test" do
|
4
|
+
it "ignores an invalid tag by default" do
|
5
|
+
html = "#{FIXTURES_DIR}/html/invalid_tag.html"
|
6
|
+
output = capture_stderr { HTML::Proofer.new(html).run }
|
7
|
+
expect(output).to eq ""
|
8
|
+
end
|
9
|
+
|
10
|
+
it "doesn't fail for html5 tags" do
|
11
|
+
html = "#{FIXTURES_DIR}/html/html5_tags.html"
|
12
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
13
|
+
expect(output).to eq ""
|
14
|
+
end
|
15
|
+
|
16
|
+
it "fails for an invalid tag" do
|
17
|
+
html = "#{FIXTURES_DIR}/html/invalid_tag.html"
|
18
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
19
|
+
expect(output).to match /Tag myfancytag invalid/
|
20
|
+
end
|
21
|
+
|
22
|
+
it "fails for an unmatched end tag" do
|
23
|
+
html = "#{FIXTURES_DIR}/html/unmatched_end_tag.html"
|
24
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
25
|
+
expect(output).to match /Unexpected end tag : div/
|
26
|
+
end
|
27
|
+
|
28
|
+
it "fails for an unescaped ampersand in attribute" do
|
29
|
+
html = "#{FIXTURES_DIR}/html/unescaped_ampersand_in_attribute.html"
|
30
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
31
|
+
expect(output).to match /htmlParseEntityRef: expecting ';'/
|
32
|
+
end
|
33
|
+
|
34
|
+
it "fails for mismatch between opening and ending tag" do
|
35
|
+
html = "#{FIXTURES_DIR}/html/opening_and_ending_tag_mismatch.html"
|
36
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
37
|
+
expect(output).to match /Opening and ending tag mismatch: p and strong/
|
38
|
+
end
|
39
|
+
|
40
|
+
it "fails for div inside head" do
|
41
|
+
html = "#{FIXTURES_DIR}/html/div_inside_head.html"
|
42
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
43
|
+
expect(output).to match /Unexpected end tag : head/
|
44
|
+
end
|
45
|
+
|
46
|
+
it "fails for missing closing quotation mark in href" do
|
47
|
+
html = "#{FIXTURES_DIR}/html/missing_closing_quotes.html"
|
48
|
+
output = capture_stderr { HTML::Proofer.new(html, {:validate_html => true}).run }
|
49
|
+
expect(output).to match /Couldn't find end of Start Tag a/
|
50
|
+
end
|
51
|
+
end
|
@@ -3,96 +3,96 @@ require "spec_helper"
|
|
3
3
|
describe "Images test" do
|
4
4
|
it "passes for existing external images" do
|
5
5
|
externalImageFilepath = "#{FIXTURES_DIR}/images/existingImageExternal.html"
|
6
|
-
|
7
|
-
|
6
|
+
proofer = make_proofer(externalImageFilepath)
|
7
|
+
expect(proofer.failed_tests).to eq []
|
8
8
|
end
|
9
9
|
|
10
10
|
it "fails for image without alt attribute" do
|
11
11
|
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
|
12
|
-
|
13
|
-
|
12
|
+
proofer = make_proofer(missingAltFilepath)
|
13
|
+
expect(proofer.failed_tests.first).to match /gpl.png does not have an alt attribute/
|
14
14
|
end
|
15
15
|
|
16
16
|
it "fails for image with an empty alt attribute" do
|
17
17
|
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAltText.html"
|
18
|
-
|
19
|
-
|
18
|
+
proofer = make_proofer(missingAltFilepath)
|
19
|
+
expect(proofer.failed_tests.first).to match /gpl.png does not have an alt attribute/
|
20
20
|
end
|
21
21
|
|
22
22
|
it "fails for missing external images" do
|
23
23
|
externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
|
24
|
-
|
25
|
-
|
24
|
+
proofer = make_proofer(externalImageFilepath)
|
25
|
+
expect(proofer.failed_tests.first).to match /External link http:\/\/www.whatthehell\/? failed: 0 Couldn't resolve host/
|
26
26
|
end
|
27
27
|
|
28
28
|
it "fails for missing internal images" do
|
29
29
|
internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
|
30
|
-
|
31
|
-
|
30
|
+
proofer = make_proofer(internalImageFilepath)
|
31
|
+
expect(proofer.failed_tests.first).to match /doesnotexist.png does not exist/
|
32
32
|
end
|
33
33
|
|
34
34
|
it "fails for image with no src" do
|
35
35
|
imageSrcFilepath = "#{FIXTURES_DIR}/images/missingImageSrc.html"
|
36
|
-
|
37
|
-
|
36
|
+
proofer = make_proofer(imageSrcFilepath)
|
37
|
+
expect(proofer.failed_tests.first).to match /image has no src attribute/
|
38
38
|
end
|
39
39
|
|
40
40
|
it "fails for image with default mac filename" do
|
41
41
|
terribleImageName = "#{FIXTURES_DIR}/images/terribleImageName.html"
|
42
|
-
|
43
|
-
|
42
|
+
proofer = make_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
|
-
|
49
|
-
|
48
|
+
proofer = make_proofer(ignorableImages)
|
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
|
-
|
55
|
-
|
54
|
+
proofer = make_proofer(relativeImages)
|
55
|
+
expect(proofer.failed_tests).to eq []
|
56
56
|
|
57
57
|
relativeImages = "#{FIXTURES_DIR}/resources/books/nestedRelativeImages.html"
|
58
|
-
|
59
|
-
|
58
|
+
proofer = make_proofer(relativeImages)
|
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
|
-
|
65
|
-
|
64
|
+
proofer = make_proofer(dataURIImage)
|
65
|
+
expect(proofer.failed_tests).to eq []
|
66
66
|
end
|
67
67
|
|
68
68
|
it "works for valid images missing the protocol" do
|
69
69
|
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
|
70
|
-
|
71
|
-
|
70
|
+
proofer = make_proofer(missingProtocolLink)
|
71
|
+
expect(proofer.failed_tests).to eq []
|
72
72
|
end
|
73
73
|
|
74
74
|
it "fails for invalid images missing the protocol" do
|
75
75
|
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
|
76
|
-
|
77
|
-
|
76
|
+
proofer = make_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
|
-
|
83
|
-
|
82
|
+
proofer = make_proofer(relativeLinks)
|
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
|
-
|
89
|
-
|
88
|
+
proofer = make_proofer(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]})
|
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
|
-
|
95
|
-
|
96
|
-
|
94
|
+
proofer = make_proofer(ignorableLinks, {:alt_ignore => [/.*/]})
|
95
|
+
expect(proofer.failed_tests.first).to match /Couldn't resolve host name/
|
96
|
+
expect(proofer.failed_tests.first).to_not match /does not have an alt attribute/
|
97
97
|
end
|
98
98
|
end
|
@@ -4,259 +4,288 @@ describe "Links test" do
|
|
4
4
|
|
5
5
|
it "fails for broken external hash (even if the file exists)" do
|
6
6
|
brokenHashExternalFilepath = "#{FIXTURES_DIR}/links/brokenHashExternal.html"
|
7
|
-
|
8
|
-
|
7
|
+
proofer = make_proofer(brokenHashExternalFilepath)
|
8
|
+
expect(proofer.failed_tests.last).to match /linking to ..\/images\/missingImageAlt.html#asdfasfdkafl, but asdfasfdkafl does not exist/
|
9
|
+
end
|
10
|
+
|
11
|
+
it "fails for broken hashes on the web (even if the file exists)" do
|
12
|
+
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
|
13
|
+
proofer = make_proofer(brokenHashOnTheWeb)
|
14
|
+
expect(proofer.failed_tests.first).to match /but the hash 'no' does not/
|
15
|
+
end
|
16
|
+
|
17
|
+
it "passes for GitHub hashes on the web" do
|
18
|
+
githubHash = "#{FIXTURES_DIR}/links/githubHash.html"
|
19
|
+
proofer = make_proofer(githubHash)
|
20
|
+
expect(proofer.failed_tests).to eq []
|
21
|
+
end
|
22
|
+
|
23
|
+
it "passes for broken hashes on the web (when we look only for 4xx)" do
|
24
|
+
options = { :only_4xx => true }
|
25
|
+
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
|
26
|
+
proofer = make_proofer(brokenHashOnTheWeb, options)
|
27
|
+
expect(proofer.failed_tests).to eq []
|
9
28
|
end
|
10
29
|
|
11
30
|
it "fails for broken internal hash" do
|
12
31
|
brokenHashInternalFilepath = "#{FIXTURES_DIR}/links/brokenHashInternal.html"
|
13
|
-
|
14
|
-
|
32
|
+
proofer = make_proofer(brokenHashInternalFilepath)
|
33
|
+
expect(proofer.failed_tests.first).to match /linking to internal hash #noHash that does not exist/
|
15
34
|
end
|
16
35
|
|
17
36
|
it "fails for broken external links" do
|
18
37
|
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkExternal.html"
|
19
|
-
|
20
|
-
|
38
|
+
proofer = make_proofer(brokenLinkExternalFilepath)
|
39
|
+
expect(proofer.failed_tests.first).to match /External link http:\/\/www.asdo3IRJ395295jsingrkrg4.com\/? failed: 0 Couldn't resolve host name/
|
21
40
|
end
|
22
41
|
|
23
42
|
it "fails for broken internal links" do
|
24
43
|
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
|
25
|
-
|
26
|
-
|
44
|
+
proofer = make_proofer(brokenLinkInternalFilepath)
|
45
|
+
expect(proofer.failed_tests.first).to match /internally linking to .\/notreal.html, which does not exist/
|
27
46
|
end
|
28
47
|
|
29
48
|
it "fails for link with no href" do
|
30
49
|
missingLinkHrefFilepath = "#{FIXTURES_DIR}/links/missingLinkHref.html"
|
31
|
-
|
32
|
-
|
50
|
+
proofer = make_proofer(missingLinkHrefFilepath)
|
51
|
+
expect(proofer.failed_tests.first).to match /anchor has no href attribute/
|
33
52
|
end
|
34
53
|
|
35
54
|
it "should follow redirects" do
|
36
55
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
37
|
-
|
38
|
-
|
56
|
+
proofer = make_proofer(linkWithRedirectFilepath)
|
57
|
+
expect(proofer.failed_tests).to eq []
|
39
58
|
end
|
40
59
|
|
41
60
|
it "fails on redirects if not following" do
|
42
|
-
options = { :followlocation => false }
|
43
61
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
44
|
-
|
45
|
-
|
62
|
+
proofer = make_proofer(linkWithRedirectFilepath, { :followlocation => false })
|
63
|
+
expect(proofer.failed_tests.first).to match /failed: 301 No error/
|
46
64
|
end
|
47
65
|
|
48
66
|
it "does not fail on redirects we're not following" do
|
49
67
|
# this test should emit a 301--see above--but we're intentionally supressing it
|
50
|
-
options = { :only_4xx => true, :followlocation => false }
|
51
68
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
52
|
-
|
53
|
-
|
69
|
+
proofer = make_proofer(linkWithRedirectFilepath, { :only_4xx => true, :followlocation => false })
|
70
|
+
expect(proofer.failed_tests).to eq []
|
54
71
|
end
|
55
72
|
|
56
73
|
it "should understand https" do
|
57
74
|
linkWithHttpsFilepath = "#{FIXTURES_DIR}/links/linkWithHttps.html"
|
58
|
-
|
59
|
-
|
75
|
+
proofer = make_proofer(linkWithHttpsFilepath)
|
76
|
+
expect(proofer.failed_tests).to eq []
|
60
77
|
end
|
61
78
|
|
62
79
|
it "fails for broken hash links with status code numbers" do
|
63
80
|
brokenLinkWithNumberFilepath = "#{FIXTURES_DIR}/links/brokenLinkWithNumber.html"
|
64
|
-
|
65
|
-
|
81
|
+
proofer = make_proofer(brokenLinkWithNumberFilepath)
|
82
|
+
expect(proofer.failed_tests.first).to match /linking to internal hash #25-method-not-allowed that does not exist/
|
66
83
|
end
|
67
84
|
|
68
85
|
it 'properly resolves implicit /index.html in link paths' do
|
69
86
|
linkToFolder = "#{FIXTURES_DIR}/links/linkToFolder.html"
|
70
|
-
|
71
|
-
|
87
|
+
proofer = make_proofer(linkToFolder)
|
88
|
+
expect(proofer.failed_tests).to eq []
|
72
89
|
end
|
73
90
|
|
74
91
|
it 'properly checks links to root' do
|
75
92
|
rootLink = "#{FIXTURES_DIR}/links/rootLink/rootLink.html"
|
76
|
-
|
77
|
-
|
93
|
+
proofer = make_proofer(rootLink)
|
94
|
+
expect(proofer.failed_tests).to eq []
|
78
95
|
end
|
79
96
|
|
80
97
|
it 'properly checks relative links' do
|
81
98
|
relativeLinks = "#{FIXTURES_DIR}/links/relativeLinks.html"
|
82
|
-
|
83
|
-
|
99
|
+
proofer = make_proofer(relativeLinks)
|
100
|
+
expect(proofer.failed_tests).to eq []
|
84
101
|
end
|
85
102
|
|
86
103
|
it 'properly checks ssl links' do
|
87
104
|
checkSSLLinks = "#{FIXTURES_DIR}/links/checkSSLLinks.html"
|
88
|
-
|
89
|
-
|
105
|
+
proofer = make_proofer(checkSSLLinks)
|
106
|
+
expect(proofer.failed_tests).to eq []
|
90
107
|
end
|
91
108
|
|
92
109
|
it 'ignores links marked as ignore data-proofer-ignore' do
|
93
110
|
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinks.html"
|
94
|
-
|
95
|
-
|
111
|
+
proofer = make_proofer(ignorableLinks)
|
112
|
+
expect(proofer.failed_tests).to eq []
|
96
113
|
end
|
97
114
|
|
98
115
|
it 'ignores links via href_ignore' do
|
99
116
|
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinksViaOptions.html"
|
100
|
-
|
101
|
-
|
117
|
+
proofer = make_proofer(ignorableLinks, {:href_ignore => [/^http:\/\//, /sdadsad/, "../whaadadt.html"]})
|
118
|
+
expect(proofer.failed_tests).to eq []
|
102
119
|
end
|
103
120
|
|
104
121
|
it 'translates links via href_swap' do
|
105
122
|
translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedViaHrefSwap.html"
|
106
|
-
|
107
|
-
|
123
|
+
proofer = make_proofer(translatedLink, {:href_swap => { /\A\/articles\/([\w-]+)/ => "\\1.html" }})
|
124
|
+
expect(proofer.failed_tests).to eq []
|
108
125
|
end
|
109
126
|
|
110
127
|
it 'finds a mix of broken and unbroken links' do
|
111
128
|
multipleProblems = "#{FIXTURES_DIR}/links/multipleProblems.html"
|
112
|
-
|
113
|
-
|
129
|
+
proofer = make_proofer(multipleProblems)
|
130
|
+
expect(proofer.failed_tests.first).to match /linking to internal hash #anadaasdadsadschor that does not exist/
|
114
131
|
end
|
115
132
|
|
116
133
|
it 'ignores valid mailto links' do
|
117
134
|
ignorableLinks = "#{FIXTURES_DIR}/links/mailto_link.html"
|
118
|
-
|
119
|
-
|
135
|
+
proofer = make_proofer(ignorableLinks)
|
136
|
+
expect(proofer.failed_tests).to eq []
|
120
137
|
end
|
121
138
|
|
122
139
|
it "fails for blank mailto links" do
|
123
140
|
blankMailToLink = "#{FIXTURES_DIR}/links/blank_mailto_link.html"
|
124
|
-
|
125
|
-
|
141
|
+
proofer = make_proofer(blankMailToLink)
|
142
|
+
expect(proofer.failed_tests.first).to match /mailto: contains no email address/
|
126
143
|
end
|
127
144
|
|
128
145
|
it 'ignores valid tel links' do
|
129
146
|
ignorableLinks = "#{FIXTURES_DIR}/links/tel_link.html"
|
130
|
-
|
131
|
-
|
147
|
+
proofer = make_proofer(ignorableLinks)
|
148
|
+
expect(proofer.failed_tests).to eq []
|
132
149
|
end
|
133
150
|
|
134
151
|
it "fails for blank tel links" do
|
135
152
|
blankTelLink = "#{FIXTURES_DIR}/links/blank_tel_link.html"
|
136
|
-
|
137
|
-
|
153
|
+
proofer = make_proofer(blankTelLink)
|
154
|
+
expect(proofer.failed_tests.first).to match /tel: contains no phone number/
|
138
155
|
end
|
139
156
|
|
140
157
|
it 'ignores javascript links' do
|
141
158
|
javascriptLink = "#{FIXTURES_DIR}/links/javascript_link.html"
|
142
|
-
|
143
|
-
|
159
|
+
proofer = make_proofer(javascriptLink)
|
160
|
+
expect(proofer.failed_tests).to eq []
|
144
161
|
end
|
145
162
|
|
146
163
|
it "works for valid links missing the protocol" do
|
147
164
|
missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_valid.html"
|
148
|
-
|
149
|
-
|
165
|
+
proofer = make_proofer(missingProtocolLink)
|
166
|
+
expect(proofer.failed_tests).to eq []
|
150
167
|
end
|
151
168
|
|
152
169
|
it "fails for invalid links missing the protocol" do
|
153
170
|
missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_invalid.html"
|
154
|
-
|
155
|
-
|
171
|
+
proofer = make_proofer(missingProtocolLink)
|
172
|
+
expect(proofer.failed_tests.first).to match /Couldn't resolve host name/
|
156
173
|
end
|
157
174
|
|
158
175
|
it "works for valid href within link elements" do
|
159
176
|
head_link = "#{FIXTURES_DIR}/links/head_link_href.html"
|
160
|
-
|
161
|
-
|
177
|
+
proofer = make_proofer(head_link)
|
178
|
+
expect(proofer.failed_tests).to eq []
|
162
179
|
end
|
163
180
|
|
164
181
|
it "fails for empty href within link elements" do
|
165
182
|
head_link = "#{FIXTURES_DIR}/links/head_link_href_empty.html"
|
166
|
-
|
167
|
-
|
183
|
+
proofer = make_proofer(head_link)
|
184
|
+
expect(proofer.failed_tests.first).to match /anchor has no href attribute/
|
168
185
|
end
|
169
186
|
|
170
187
|
it "fails for absent href within link elements" do
|
171
188
|
head_link = "#{FIXTURES_DIR}/links/head_link_href_absent.html"
|
172
|
-
|
173
|
-
|
189
|
+
proofer = make_proofer(head_link)
|
190
|
+
expect(proofer.failed_tests.first).to match /anchor has no href attribute/
|
174
191
|
end
|
175
192
|
|
176
193
|
it "fails for internal linking to a directory without trailing slash" do
|
177
194
|
options = { :followlocation => false }
|
178
195
|
internal = "#{FIXTURES_DIR}/links/link_directory_without_slash.html"
|
179
|
-
|
180
|
-
|
196
|
+
proofer = make_proofer(internal, options)
|
197
|
+
expect(proofer.failed_tests.first).to match /without trailing slash/
|
181
198
|
end
|
182
199
|
|
183
200
|
it "works for array of links" do
|
184
|
-
|
185
|
-
|
201
|
+
proofer = make_proofer(["www.github.com", "foofoofoo.biz"])
|
202
|
+
expect(proofer.failed_tests.first).to match /foofoofoo.biz\/? failed: 0 Couldn't resolve host name/
|
186
203
|
end
|
187
204
|
|
188
205
|
it "works for broken anchors within pre" do
|
189
206
|
anchor_pre = "#{FIXTURES_DIR}/links/anchors_in_pre.html"
|
190
|
-
|
191
|
-
|
207
|
+
proofer = make_proofer(anchor_pre)
|
208
|
+
expect(proofer.failed_tests).to eq []
|
192
209
|
end
|
193
210
|
|
194
211
|
it "works for broken link within pre" do
|
195
212
|
link_pre = "#{FIXTURES_DIR}/links/links_in_pre.html"
|
196
|
-
|
197
|
-
|
213
|
+
proofer = make_proofer(link_pre)
|
214
|
+
expect(proofer.failed_tests).to eq []
|
198
215
|
end
|
199
216
|
|
200
217
|
it "works for pipes in the URL" do
|
201
218
|
escape_pipes = "#{FIXTURES_DIR}/links/escape_pipes.html"
|
202
|
-
|
203
|
-
|
219
|
+
proofer = make_proofer(escape_pipes)
|
220
|
+
expect(proofer.failed_tests).to eq []
|
204
221
|
end
|
205
222
|
|
206
223
|
it "fails for broken hash with query" do
|
207
224
|
broken_hash = "#{FIXTURES_DIR}/links/broken_hash_with_query.html"
|
208
|
-
|
209
|
-
|
225
|
+
proofer = make_proofer(broken_hash)
|
226
|
+
expect(proofer.failed_tests.first).to match /linking to internal hash #example that does not exist/
|
210
227
|
end
|
211
228
|
|
212
229
|
it "works for directory index file" do
|
213
230
|
options = { :directory_index_file => "index.php" }
|
214
231
|
link_pointing_to_directory = "#{FIXTURES_DIR}/links/link_pointing_to_directory.html"
|
215
|
-
|
216
|
-
|
232
|
+
proofer = make_proofer(link_pointing_to_directory, options)
|
233
|
+
expect(proofer.failed_tests).to eq []
|
217
234
|
end
|
218
235
|
|
219
236
|
it "fails if directory index file doesn't exist" do
|
220
237
|
options = { :directory_index_file => "README.md" }
|
221
238
|
link_pointing_to_directory = "#{FIXTURES_DIR}/links/link_pointing_to_directory.html"
|
222
|
-
|
223
|
-
|
239
|
+
proofer = make_proofer(link_pointing_to_directory, options)
|
240
|
+
expect(proofer.failed_tests.first).to match "internally linking to folder-php/, which does not exist"
|
224
241
|
end
|
225
242
|
|
226
243
|
it "ensures Typhoeus options are passed" do
|
227
244
|
options = { ssl_verifypeer: false }
|
228
245
|
typhoeus_options_link = "#{FIXTURES_DIR}/links/ensure_typhoeus_options.html"
|
229
|
-
|
230
|
-
|
246
|
+
proofer = make_proofer(typhoeus_options_link, options)
|
247
|
+
expect(proofer.failed_tests).to eq []
|
231
248
|
end
|
232
249
|
|
233
250
|
it "works if subdirectory ends with .html" do
|
234
251
|
with_subdirectory_html = "#{FIXTURES_DIR}/links/_site"
|
235
|
-
|
236
|
-
|
252
|
+
proofer = make_proofer(with_subdirectory_html)
|
253
|
+
expect(proofer.failed_tests).to eq []
|
237
254
|
end
|
238
255
|
|
239
256
|
it "works for hash referring to itself" do
|
240
257
|
hashReferringToSelf = "#{FIXTURES_DIR}/links/hashReferringToSelf.html"
|
241
|
-
|
242
|
-
|
258
|
+
proofer = make_proofer(hashReferringToSelf)
|
259
|
+
expect(proofer.failed_tests).to eq []
|
243
260
|
end
|
244
261
|
|
245
262
|
it "ignores placeholder with name" do
|
246
263
|
placeholder_with_name = "#{FIXTURES_DIR}/links/placeholder_with_name.html"
|
247
|
-
|
248
|
-
|
264
|
+
proofer = make_proofer(placeholder_with_name)
|
265
|
+
expect(proofer.failed_tests).to eq []
|
249
266
|
end
|
250
267
|
|
251
268
|
it "ignores placeholder with id" do
|
252
269
|
placeholder_with_id = "#{FIXTURES_DIR}/links/placeholder_with_id.html"
|
253
|
-
|
254
|
-
|
270
|
+
proofer = make_proofer(placeholder_with_id)
|
271
|
+
expect(proofer.failed_tests).to eq []
|
255
272
|
end
|
256
273
|
|
257
274
|
it "fails for placeholder with empty id" do
|
258
275
|
empty_id = "#{FIXTURES_DIR}/links/placeholder_with_empty_id.html"
|
259
|
-
|
260
|
-
|
276
|
+
proofer = make_proofer(empty_id)
|
277
|
+
expect(proofer.failed_tests.first).to match /anchor has no href attribute/
|
278
|
+
end
|
279
|
+
|
280
|
+
it "ignores non-http(s) protocols" do
|
281
|
+
other_protocols = "#{FIXTURES_DIR}/links/other_protocols.html"
|
282
|
+
proofer = make_proofer(other_protocols)
|
283
|
+
expect(proofer.failed_tests).to eq []
|
284
|
+
end
|
285
|
+
|
286
|
+
it "passes non-standard characters" do
|
287
|
+
fixture = "#{FIXTURES_DIR}/links/non_standard_characters.html"
|
288
|
+
proofer = make_proofer(fixture)
|
289
|
+
expect(proofer.failed_tests).to eq []
|
261
290
|
end
|
262
291
|
end
|