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,309 +1,352 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Links test' do
|
4
4
|
|
5
|
-
it
|
5
|
+
it 'fails for broken internal hash (even if the file exists)' do
|
6
6
|
brokenHashExternalFilepath = "#{FIXTURES_DIR}/links/brokenHashExternal.html"
|
7
|
-
proofer =
|
8
|
-
expect(proofer.failed_tests.last).to match
|
7
|
+
proofer = run_proofer(brokenHashExternalFilepath)
|
8
|
+
expect(proofer.failed_tests.last).to match(%r{linking to ../images/missingImageAlt.html#asdfasfdkafl, but asdfasfdkafl does not exist})
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'fails for broken hashes on the web when asked (even if the file exists)' do
|
12
12
|
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
|
13
|
-
proofer =
|
14
|
-
expect(proofer.failed_tests.first).to match
|
13
|
+
proofer = run_proofer(brokenHashOnTheWeb, { :check_external_hash => true} )
|
14
|
+
expect(proofer.failed_tests.first).to match(/but the hash 'no' does not/)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'passes for broken hashes on the web when ignored (even if the file exists)' do
|
18
18
|
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
|
19
|
-
proofer =
|
19
|
+
proofer = run_proofer(brokenHashOnTheWeb)
|
20
20
|
expect(proofer.failed_tests).to eq []
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'passes for GitHub hashes on the web when asked' do
|
24
24
|
githubHash = "#{FIXTURES_DIR}/links/githubHash.html"
|
25
|
-
proofer =
|
25
|
+
proofer = run_proofer(githubHash)
|
26
26
|
expect(proofer.failed_tests).to eq []
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'passes for broken hashes on the web (when we look only for 4xx)' do
|
30
30
|
options = { :only_4xx => true }
|
31
31
|
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
|
32
|
-
proofer =
|
32
|
+
proofer = run_proofer(brokenHashOnTheWeb, options)
|
33
33
|
expect(proofer.failed_tests).to eq []
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'fails for broken internal hash' do
|
37
37
|
brokenHashInternalFilepath = "#{FIXTURES_DIR}/links/brokenHashInternal.html"
|
38
|
-
proofer =
|
39
|
-
expect(proofer.failed_tests.first).to match
|
38
|
+
proofer = run_proofer(brokenHashInternalFilepath)
|
39
|
+
expect(proofer.failed_tests.first).to match(/linking to internal hash #noHash that does not exist/)
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it 'fails for broken external links' do
|
43
43
|
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkExternal.html"
|
44
|
-
proofer =
|
45
|
-
expect(proofer.failed_tests.first).to match
|
44
|
+
proofer = run_proofer(brokenLinkExternalFilepath)
|
45
|
+
expect(proofer.failed_tests.first).to match(/failed: 0 Couldn't resolve host name/)
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it 'passes for different filename without option' do
|
49
|
+
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/links/file.foo"
|
50
|
+
proofer = run_proofer(brokenLinkExternalFilepath)
|
51
|
+
expect(proofer.failed_tests).to eq []
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'fails for different filenames' do
|
55
|
+
options = { :ext => '.foo' }
|
56
|
+
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/links/file.foo"
|
57
|
+
proofer = run_proofer(brokenLinkExternalFilepath, options)
|
58
|
+
expect(proofer.failed_tests.first).to match(/failed: 0 Couldn't resolve host name/)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'fails for broken internal links' do
|
49
62
|
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
|
50
|
-
proofer =
|
51
|
-
expect(proofer.failed_tests.first).to match
|
63
|
+
proofer = run_proofer(brokenLinkInternalFilepath)
|
64
|
+
expect(proofer.failed_tests.first).to match(/internally linking to .\/notreal.html, which does not exist/)
|
52
65
|
end
|
53
66
|
|
54
|
-
it
|
67
|
+
it 'fails for link with no href' do
|
55
68
|
missingLinkHrefFilepath = "#{FIXTURES_DIR}/links/missingLinkHref.html"
|
56
|
-
proofer =
|
57
|
-
expect(proofer.failed_tests.first).to match
|
69
|
+
proofer = run_proofer(missingLinkHrefFilepath)
|
70
|
+
expect(proofer.failed_tests.first).to match(/anchor has no href attribute/)
|
58
71
|
end
|
59
72
|
|
60
|
-
it
|
73
|
+
it 'should follow redirects' do
|
61
74
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
62
|
-
proofer =
|
75
|
+
proofer = run_proofer(linkWithRedirectFilepath)
|
63
76
|
expect(proofer.failed_tests).to eq []
|
64
77
|
end
|
65
78
|
|
66
|
-
it
|
79
|
+
it 'fails on redirects if not following' do
|
67
80
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
68
|
-
proofer =
|
69
|
-
expect(proofer.failed_tests.first).to match
|
81
|
+
proofer = run_proofer(linkWithRedirectFilepath, :typhoeus => { :followlocation => false })
|
82
|
+
expect(proofer.failed_tests.first).to match(/failed: 301 No error/)
|
70
83
|
end
|
71
84
|
|
72
85
|
it "does not fail on redirects we're not following" do
|
73
86
|
# this test should emit a 301--see above--but we're intentionally supressing it
|
74
87
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
75
|
-
proofer =
|
88
|
+
proofer = run_proofer(linkWithRedirectFilepath, { :only_4xx => true, :typhoeus => { :followlocation => false } })
|
76
89
|
expect(proofer.failed_tests).to eq []
|
77
90
|
end
|
78
91
|
|
79
|
-
it
|
92
|
+
it 'should understand https' do
|
80
93
|
linkWithHttpsFilepath = "#{FIXTURES_DIR}/links/linkWithHttps.html"
|
81
|
-
proofer =
|
94
|
+
proofer = run_proofer(linkWithHttpsFilepath)
|
82
95
|
expect(proofer.failed_tests).to eq []
|
83
96
|
end
|
84
97
|
|
85
|
-
it
|
98
|
+
it 'fails for broken hash links with status code numbers' do
|
86
99
|
brokenLinkWithNumberFilepath = "#{FIXTURES_DIR}/links/brokenLinkWithNumber.html"
|
87
|
-
proofer =
|
88
|
-
expect(proofer.failed_tests.first).to match
|
100
|
+
proofer = run_proofer(brokenLinkWithNumberFilepath)
|
101
|
+
expect(proofer.failed_tests.first).to match(/linking to internal hash #25-method-not-allowed that does not exist/)
|
89
102
|
end
|
90
103
|
|
91
104
|
it 'properly resolves implicit /index.html in link paths' do
|
92
105
|
linkToFolder = "#{FIXTURES_DIR}/links/linkToFolder.html"
|
93
|
-
proofer =
|
106
|
+
proofer = run_proofer(linkToFolder)
|
94
107
|
expect(proofer.failed_tests).to eq []
|
95
108
|
end
|
96
109
|
|
97
110
|
it 'properly checks links to root' do
|
98
111
|
rootLink = "#{FIXTURES_DIR}/links/rootLink/rootLink.html"
|
99
|
-
proofer =
|
112
|
+
proofer = run_proofer(rootLink)
|
100
113
|
expect(proofer.failed_tests).to eq []
|
101
114
|
end
|
102
115
|
|
103
116
|
it 'properly checks relative links' do
|
104
117
|
relativeLinks = "#{FIXTURES_DIR}/links/relativeLinks.html"
|
105
|
-
proofer =
|
118
|
+
proofer = run_proofer(relativeLinks)
|
106
119
|
expect(proofer.failed_tests).to eq []
|
107
120
|
end
|
108
121
|
|
109
122
|
it 'properly checks ssl links' do
|
110
123
|
checkSSLLinks = "#{FIXTURES_DIR}/links/checkSSLLinks.html"
|
111
|
-
proofer =
|
124
|
+
proofer = run_proofer(checkSSLLinks)
|
112
125
|
expect(proofer.failed_tests).to eq []
|
113
126
|
end
|
114
127
|
|
115
128
|
it 'ignores links marked as ignore data-proofer-ignore' do
|
116
129
|
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinks.html"
|
117
|
-
proofer =
|
130
|
+
proofer = run_proofer(ignorableLinks)
|
118
131
|
expect(proofer.failed_tests).to eq []
|
119
132
|
end
|
120
133
|
|
121
134
|
it 'ignores links via href_ignore' do
|
122
135
|
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinksViaOptions.html"
|
123
|
-
proofer =
|
136
|
+
proofer = run_proofer(ignorableLinks, { :href_ignore => [%r{^http://}, /sdadsad/, '../whaadadt.html'] })
|
124
137
|
expect(proofer.failed_tests).to eq []
|
125
138
|
end
|
126
139
|
|
127
140
|
it 'translates links via href_swap' do
|
128
141
|
translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedViaHrefSwap.html"
|
129
|
-
proofer =
|
142
|
+
proofer = run_proofer(translatedLink, { :href_swap => { %r{\A/articles/([\w-]+)} => "\\1.html" } })
|
143
|
+
expect(proofer.failed_tests).to eq []
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'translates links via href_swap for list of links' do
|
147
|
+
proofer = run_proofer(['www.garbalarba.com'], { :href_swap => { /garbalarba/ => 'github' } })
|
130
148
|
expect(proofer.failed_tests).to eq []
|
131
149
|
end
|
132
150
|
|
133
151
|
it 'finds a mix of broken and unbroken links' do
|
134
152
|
multipleProblems = "#{FIXTURES_DIR}/links/multipleProblems.html"
|
135
|
-
proofer =
|
136
|
-
expect(proofer.failed_tests.first).to match
|
153
|
+
proofer = run_proofer(multipleProblems)
|
154
|
+
expect(proofer.failed_tests.first).to match(/linking to internal hash #anadaasdadsadschor that does not exist/)
|
137
155
|
end
|
138
156
|
|
139
157
|
it 'ignores valid mailto links' do
|
140
158
|
ignorableLinks = "#{FIXTURES_DIR}/links/mailto_link.html"
|
141
|
-
proofer =
|
159
|
+
proofer = run_proofer(ignorableLinks)
|
142
160
|
expect(proofer.failed_tests).to eq []
|
143
161
|
end
|
144
162
|
|
145
|
-
it
|
163
|
+
it 'fails for blank mailto links' do
|
146
164
|
blankMailToLink = "#{FIXTURES_DIR}/links/blank_mailto_link.html"
|
147
|
-
proofer =
|
148
|
-
expect(proofer.failed_tests.first).to match
|
165
|
+
proofer = run_proofer(blankMailToLink)
|
166
|
+
expect(proofer.failed_tests.first).to match(/mailto: contains no email address/)
|
149
167
|
end
|
150
168
|
|
151
169
|
it 'ignores valid tel links' do
|
152
170
|
ignorableLinks = "#{FIXTURES_DIR}/links/tel_link.html"
|
153
|
-
proofer =
|
171
|
+
proofer = run_proofer(ignorableLinks)
|
154
172
|
expect(proofer.failed_tests).to eq []
|
155
173
|
end
|
156
174
|
|
157
|
-
it
|
175
|
+
it 'fails for blank tel links' do
|
158
176
|
blankTelLink = "#{FIXTURES_DIR}/links/blank_tel_link.html"
|
159
|
-
proofer =
|
160
|
-
expect(proofer.failed_tests.first).to match
|
177
|
+
proofer = run_proofer(blankTelLink)
|
178
|
+
expect(proofer.failed_tests.first).to match(/tel: contains no phone number/)
|
161
179
|
end
|
162
180
|
|
163
181
|
it 'ignores javascript links' do
|
164
182
|
javascriptLink = "#{FIXTURES_DIR}/links/javascript_link.html"
|
165
|
-
proofer =
|
183
|
+
proofer = run_proofer(javascriptLink)
|
166
184
|
expect(proofer.failed_tests).to eq []
|
167
185
|
end
|
168
186
|
|
169
|
-
it
|
187
|
+
it 'works for valid links missing the protocol' do
|
170
188
|
missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_valid.html"
|
171
|
-
proofer =
|
189
|
+
proofer = run_proofer(missingProtocolLink)
|
172
190
|
expect(proofer.failed_tests).to eq []
|
173
191
|
end
|
174
192
|
|
175
|
-
it
|
193
|
+
it 'fails for invalid links missing the protocol' do
|
176
194
|
missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_invalid.html"
|
177
|
-
proofer =
|
178
|
-
expect(proofer.failed_tests.first).to match
|
195
|
+
proofer = run_proofer(missingProtocolLink)
|
196
|
+
expect(proofer.failed_tests.first).to match(/Couldn't resolve host name/)
|
179
197
|
end
|
180
198
|
|
181
|
-
it
|
199
|
+
it 'works for valid href within link elements' do
|
182
200
|
head_link = "#{FIXTURES_DIR}/links/head_link_href.html"
|
183
|
-
proofer =
|
201
|
+
proofer = run_proofer(head_link)
|
184
202
|
expect(proofer.failed_tests).to eq []
|
185
203
|
end
|
186
204
|
|
187
|
-
it
|
205
|
+
it 'fails for empty href within link elements' do
|
188
206
|
head_link = "#{FIXTURES_DIR}/links/head_link_href_empty.html"
|
189
|
-
proofer =
|
190
|
-
expect(proofer.failed_tests.first).to match
|
207
|
+
proofer = run_proofer(head_link)
|
208
|
+
expect(proofer.failed_tests.first).to match(/anchor has no href attribute/)
|
191
209
|
end
|
192
210
|
|
193
|
-
it
|
211
|
+
it 'fails for absent href within link elements' do
|
194
212
|
head_link = "#{FIXTURES_DIR}/links/head_link_href_absent.html"
|
195
|
-
proofer =
|
196
|
-
expect(proofer.failed_tests.first).to match
|
213
|
+
proofer = run_proofer(head_link)
|
214
|
+
expect(proofer.failed_tests.first).to match(/anchor has no href attribute/)
|
197
215
|
end
|
198
216
|
|
199
|
-
it
|
200
|
-
options = { :followlocation => false }
|
217
|
+
it 'fails for internal linking to a directory without trailing slash' do
|
218
|
+
options = { :typhoeus => { :followlocation => false } }
|
201
219
|
internal = "#{FIXTURES_DIR}/links/link_directory_without_slash.html"
|
202
|
-
proofer =
|
203
|
-
expect(proofer.failed_tests.first).to match
|
220
|
+
proofer = run_proofer(internal, options)
|
221
|
+
expect(proofer.failed_tests.first).to match(/without trailing slash/)
|
204
222
|
end
|
205
223
|
|
206
|
-
it
|
207
|
-
|
208
|
-
|
224
|
+
it 'ignores external links when asked' do
|
225
|
+
options = { :disable_external => true }
|
226
|
+
external = "#{FIXTURES_DIR}/links/brokenLinkExternal.html"
|
227
|
+
proofer = run_proofer(external, options)
|
228
|
+
expect(proofer.failed_tests).to eq []
|
209
229
|
end
|
210
230
|
|
211
|
-
it
|
231
|
+
it 'works for array of links' do
|
232
|
+
proofer = run_proofer(['www.github.com', 'foofoofoo.biz'])
|
233
|
+
expect(proofer.failed_tests.first).to match(/failed: 0 Couldn't resolve host name/)
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'works for broken anchors within pre' do
|
212
237
|
anchor_pre = "#{FIXTURES_DIR}/links/anchors_in_pre.html"
|
213
|
-
proofer =
|
238
|
+
proofer = run_proofer(anchor_pre)
|
214
239
|
expect(proofer.failed_tests).to eq []
|
215
240
|
end
|
216
241
|
|
217
|
-
it
|
242
|
+
it 'works for broken link within pre' do
|
218
243
|
link_pre = "#{FIXTURES_DIR}/links/links_in_pre.html"
|
219
|
-
proofer =
|
244
|
+
proofer = run_proofer(link_pre)
|
220
245
|
expect(proofer.failed_tests).to eq []
|
221
246
|
end
|
222
247
|
|
223
|
-
it
|
248
|
+
it 'works for pipes in the URL' do
|
224
249
|
escape_pipes = "#{FIXTURES_DIR}/links/escape_pipes.html"
|
225
|
-
proofer =
|
250
|
+
proofer = run_proofer(escape_pipes)
|
226
251
|
expect(proofer.failed_tests).to eq []
|
227
252
|
end
|
228
253
|
|
229
|
-
it
|
254
|
+
it 'fails for broken hash with query' do
|
230
255
|
broken_hash = "#{FIXTURES_DIR}/links/broken_hash_with_query.html"
|
231
|
-
proofer =
|
232
|
-
expect(proofer.failed_tests.first).to match
|
256
|
+
proofer = run_proofer(broken_hash)
|
257
|
+
expect(proofer.failed_tests.first).to match(/linking to internal hash #example that does not exist/)
|
233
258
|
end
|
234
259
|
|
235
|
-
it
|
260
|
+
it 'works for directory index file' do
|
236
261
|
options = { :directory_index_file => "index.php" }
|
237
262
|
link_pointing_to_directory = "#{FIXTURES_DIR}/links/link_pointing_to_directory.html"
|
238
|
-
proofer =
|
263
|
+
proofer = run_proofer(link_pointing_to_directory, options)
|
239
264
|
expect(proofer.failed_tests).to eq []
|
240
265
|
end
|
241
266
|
|
242
267
|
it "fails if directory index file doesn't exist" do
|
243
268
|
options = { :directory_index_file => "README.md" }
|
244
269
|
link_pointing_to_directory = "#{FIXTURES_DIR}/links/link_pointing_to_directory.html"
|
245
|
-
proofer =
|
270
|
+
proofer = run_proofer(link_pointing_to_directory, options)
|
246
271
|
expect(proofer.failed_tests.first).to match "internally linking to folder-php/, which does not exist"
|
247
272
|
end
|
248
273
|
|
249
|
-
it
|
250
|
-
options = {
|
274
|
+
it 'ensures Typhoeus options are passed' do
|
275
|
+
options = { :typhoeus => { :ssl_verifypeer => false } }
|
251
276
|
typhoeus_options_link = "#{FIXTURES_DIR}/links/ensure_typhoeus_options.html"
|
252
|
-
proofer =
|
277
|
+
proofer = run_proofer(typhoeus_options_link, options)
|
253
278
|
expect(proofer.failed_tests).to eq []
|
254
279
|
end
|
255
280
|
|
256
|
-
it
|
281
|
+
it 'works if subdirectory ends with .html' do
|
257
282
|
with_subdirectory_html = "#{FIXTURES_DIR}/links/_site"
|
258
|
-
proofer =
|
283
|
+
proofer = run_proofer(with_subdirectory_html)
|
259
284
|
expect(proofer.failed_tests).to eq []
|
260
285
|
end
|
261
286
|
|
262
|
-
it
|
287
|
+
it 'works for hash referring to itself' do
|
263
288
|
hashReferringToSelf = "#{FIXTURES_DIR}/links/hashReferringToSelf.html"
|
264
|
-
proofer =
|
289
|
+
proofer = run_proofer(hashReferringToSelf)
|
265
290
|
expect(proofer.failed_tests).to eq []
|
266
291
|
end
|
267
292
|
|
268
|
-
it
|
293
|
+
it 'ignores placeholder with name' do
|
269
294
|
placeholder_with_name = "#{FIXTURES_DIR}/links/placeholder_with_name.html"
|
270
|
-
proofer =
|
295
|
+
proofer = run_proofer(placeholder_with_name)
|
271
296
|
expect(proofer.failed_tests).to eq []
|
272
297
|
end
|
273
298
|
|
274
|
-
it
|
299
|
+
it 'ignores placeholder with id' do
|
275
300
|
placeholder_with_id = "#{FIXTURES_DIR}/links/placeholder_with_id.html"
|
276
|
-
proofer =
|
301
|
+
proofer = run_proofer(placeholder_with_id)
|
277
302
|
expect(proofer.failed_tests).to eq []
|
278
303
|
end
|
279
304
|
|
280
|
-
it
|
305
|
+
it 'fails for placeholder with empty id' do
|
281
306
|
empty_id = "#{FIXTURES_DIR}/links/placeholder_with_empty_id.html"
|
282
|
-
proofer =
|
283
|
-
expect(proofer.failed_tests.first).to match
|
307
|
+
proofer = run_proofer(empty_id)
|
308
|
+
expect(proofer.failed_tests.first).to match(/anchor has no href attribute/)
|
284
309
|
end
|
285
310
|
|
286
|
-
it
|
311
|
+
it 'ignores non-http(s) protocols' do
|
287
312
|
other_protocols = "#{FIXTURES_DIR}/links/other_protocols.html"
|
288
|
-
proofer =
|
313
|
+
proofer = run_proofer(other_protocols)
|
289
314
|
expect(proofer.failed_tests).to eq []
|
290
315
|
end
|
291
316
|
|
292
|
-
it
|
317
|
+
it 'passes non-standard characters' do
|
293
318
|
fixture = "#{FIXTURES_DIR}/links/non_standard_characters.html"
|
294
|
-
proofer =
|
319
|
+
proofer = run_proofer(fixture)
|
295
320
|
expect(proofer.failed_tests).to eq []
|
296
321
|
end
|
297
322
|
|
298
|
-
it
|
323
|
+
it 'does not dupe errors' do
|
299
324
|
fixture = "#{FIXTURES_DIR}/links/nodupe.html"
|
300
|
-
proofer =
|
325
|
+
proofer = run_proofer(fixture)
|
301
326
|
expect(proofer.failed_tests.length).to eq 1
|
302
327
|
end
|
303
328
|
|
304
|
-
it
|
329
|
+
it 'passes for broken *nix links' do
|
305
330
|
fixture = "#{FIXTURES_DIR}/links/brokenUnixLinks.html"
|
306
|
-
proofer =
|
331
|
+
proofer = run_proofer(fixture)
|
307
332
|
expect(proofer.failed_tests).to eq []
|
308
333
|
end
|
334
|
+
|
335
|
+
it 'passes for external UTF-8 links' do
|
336
|
+
fixture = "#{FIXTURES_DIR}/links/utf8Link.html"
|
337
|
+
proofer = run_proofer(fixture)
|
338
|
+
expect(proofer.failed_tests).to eq []
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'passes for urlencoded href' do
|
342
|
+
fixture = "#{FIXTURES_DIR}/links/urlencoded-href.html"
|
343
|
+
proofer = run_proofer(fixture)
|
344
|
+
expect(proofer.failed_tests).to eq []
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'reports failures for the original link, not the redirection' do
|
348
|
+
fixture = "#{FIXTURES_DIR}/links/redirected_error.html"
|
349
|
+
proofer = run_proofer(fixture)
|
350
|
+
expect(proofer.failed_tests.first).to match(/post.htm\?id=63009224 failed: 404 No error/)
|
351
|
+
end
|
309
352
|
end
|
@@ -1,40 +1,40 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Scripts test' do
|
4
4
|
|
5
|
-
it
|
5
|
+
it 'fails for broken external src' do
|
6
6
|
file = "#{FIXTURES_DIR}/scripts/script_broken_external.html"
|
7
|
-
proofer =
|
8
|
-
expect(proofer.failed_tests.first).to match
|
7
|
+
proofer = run_proofer(file)
|
8
|
+
expect(proofer.failed_tests.first).to match(/failed: 0 Couldn't resolve host name/)
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'works for valid internal src' do
|
12
12
|
file = "#{FIXTURES_DIR}/scripts/script_valid_internal.html"
|
13
|
-
proofer =
|
13
|
+
proofer = run_proofer(file)
|
14
14
|
expect(proofer.failed_tests).to eq []
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'fails for missing internal src' do
|
18
18
|
file = "#{FIXTURES_DIR}/scripts/script_missing_internal.html"
|
19
|
-
proofer =
|
20
|
-
expect(proofer.failed_tests.first).to match
|
19
|
+
proofer = run_proofer(file)
|
20
|
+
expect(proofer.failed_tests.first).to match(/doesnotexist.js does not exist \(line 5\)/)
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'works for present content' do
|
24
24
|
file = "#{FIXTURES_DIR}/scripts/script_content.html"
|
25
|
-
proofer =
|
25
|
+
proofer = run_proofer(file)
|
26
26
|
expect(proofer.failed_tests).to eq []
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'fails for absent content' do
|
30
30
|
file = "#{FIXTURES_DIR}/scripts/script_content_absent.html"
|
31
|
-
proofer =
|
32
|
-
expect(proofer.failed_tests.first).to match
|
31
|
+
proofer = run_proofer(file)
|
32
|
+
expect(proofer.failed_tests.first).to match(/script is empty and has no src attribute/)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it 'works for broken script within pre' do
|
36
36
|
script_pre = "#{FIXTURES_DIR}/scripts/script_in_pre.html"
|
37
|
-
proofer =
|
37
|
+
proofer = run_proofer(script_pre)
|
38
38
|
expect(proofer.failed_tests).to eq []
|
39
39
|
end
|
40
40
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HTML::Utils do
|
4
|
+
describe '::create_nokogiri' do
|
5
|
+
it 'passes for a string' do
|
6
|
+
noko = HTML::Utils::create_nokogiri '<html lang="jp">'
|
7
|
+
expect(noko.css('html').first['lang']).to eq 'jp'
|
8
|
+
end
|
9
|
+
it 'passes for a file' do
|
10
|
+
noko = HTML::Utils::create_nokogiri "#{FIXTURES_DIR}/utils/lang-jp.html"
|
11
|
+
expect(noko.css('html').first['lang']).to eq 'jp'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|