html-proofer 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <p>Blah blah blah. <img src="./gpl.png" alt=""/> </p>
6
+ <p>Blah blah blah. <img src="./gpl.png" alt=" "/> </p>
7
+ <p>Blah blah blah. <img src="./gpl.png" alt/> </p>
8
+ </body>
9
+
10
+ </html>
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <a href="mailto:octocat">Meow me</a>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -13,6 +13,12 @@ describe 'Html test' do
13
13
  expect(proofer.failed_tests).to eq []
14
14
  end
15
15
 
16
+ it "doesn't fail for svg elements" do
17
+ html = "#{FIXTURES_DIR}/html/svg_elements.html"
18
+ proofer = run_proofer(html, { :check_html => true })
19
+ expect(proofer.failed_tests).to eq []
20
+ end
21
+
16
22
  it 'fails for an invalid tag' do
17
23
  html = "#{FIXTURES_DIR}/html/invalid_tag.html"
18
24
  proofer = run_proofer(html, { :check_html => true })
@@ -19,6 +19,19 @@ describe 'Images test' do
19
19
  expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
20
20
  end
21
21
 
22
+ it 'fails for image with nothing but spaces in alt attribute' do
23
+ emptyAltFilepath = "#{FIXTURES_DIR}/images/emptyImageAltText.html"
24
+ proofer = run_proofer(emptyAltFilepath)
25
+ expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
26
+ expect(proofer.failed_tests.length).to equal(3)
27
+ end
28
+
29
+ it 'passes when ignoring image with nothing but spaces in alt attribute' do
30
+ emptyAltFilepath = "#{FIXTURES_DIR}/images/emptyImageAltText.html"
31
+ proofer = run_proofer(emptyAltFilepath, {:alt_ignore => [/.+/]})
32
+ expect(proofer.failed_tests).to eq []
33
+ end
34
+
22
35
  it 'fails for missing external images' do
23
36
  externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
24
37
  proofer = run_proofer(externalImageFilepath)
@@ -96,6 +109,18 @@ describe 'Images test' do
96
109
  expect(proofer.failed_tests.first).to_not match /does not have an alt attribute/
97
110
  end
98
111
 
112
+ it 'properly ignores empty alt attribute when empty_alt_ignore set' do
113
+ missingAltFilepath = "#{FIXTURES_DIR}/images/emptyImageAltText.html"
114
+ proofer = run_proofer(missingAltFilepath, {:empty_alt_ignore => true})
115
+ expect(proofer.failed_tests).to eq []
116
+ end
117
+
118
+ it 'properly ignores empty alt attributes, but not missing alt attributes, when empty_alt_ignore set' do
119
+ missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
120
+ proofer = run_proofer(missingAltFilepath, {:empty_alt_ignore => true})
121
+ expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
122
+ end
123
+
99
124
  it 'works for images with a srcset' do
100
125
  srcSetCheck = "#{FIXTURES_DIR}/images/srcSetCheck.html"
101
126
  proofer = run_proofer(srcSetCheck)
@@ -166,6 +166,12 @@ describe 'Links test' do
166
166
  expect(proofer.failed_tests.first).to match(/mailto: contains no email address/)
167
167
  end
168
168
 
169
+ it 'fails for invalid mailto links' do
170
+ invalidMailToLink = "#{FIXTURES_DIR}/links/invalid_mailto_link.html"
171
+ proofer = run_proofer(invalidMailToLink)
172
+ expect(proofer.failed_tests.first).to match(/mailto:octocat contains an invalid email address/)
173
+ end
174
+
169
175
  it 'ignores valid tel links' do
170
176
  ignorableLinks = "#{FIXTURES_DIR}/links/tel_link.html"
171
177
  proofer = run_proofer(ignorableLinks)
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'bundler/setup'
2
5
  require_relative "../lib/html/proofer"
3
6
 
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: 2.1.0
4
+ version: 2.2.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: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -193,6 +193,8 @@ files:
193
193
  - lib/html/proofer/url_validator.rb
194
194
  - lib/html/proofer/utils.rb
195
195
  - lib/html/proofer/version.rb
196
+ - script/bootstrap
197
+ - spec/html/proofer/checkable_spec.rb
196
198
  - spec/html/proofer/command_spec.rb
197
199
  - spec/html/proofer/favicon_spec.rb
198
200
  - spec/html/proofer/fixtures/favicon/favicon_absent.html
@@ -206,8 +208,10 @@ files:
206
208
  - spec/html/proofer/fixtures/html/invalid_tag.html
207
209
  - spec/html/proofer/fixtures/html/missing_closing_quotes.html
208
210
  - spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html
211
+ - spec/html/proofer/fixtures/html/svg_elements.html
209
212
  - spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html
210
213
  - spec/html/proofer/fixtures/html/unmatched_end_tag.html
214
+ - spec/html/proofer/fixtures/images/emptyImageAltText.html
211
215
  - spec/html/proofer/fixtures/images/existingImageExternal.html
212
216
  - spec/html/proofer/fixtures/images/gpl.png
213
217
  - spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
@@ -244,7 +248,7 @@ files:
244
248
  - spec/html/proofer/fixtures/links/broken_hash_with_query.html
245
249
  - spec/html/proofer/fixtures/links/checkSSLLinks.html
246
250
  - spec/html/proofer/fixtures/links/ensure_typhoeus_options.html
247
- - spec/html/proofer/fixtures/links/erstiebegrüßung.html
251
+ - spec/html/proofer/fixtures/links/erstiebegr%C3%BC%C3%9Fung.html
248
252
  - spec/html/proofer/fixtures/links/erstiebegrüßung.html
249
253
  - spec/html/proofer/fixtures/links/escape_pipes.html
250
254
  - spec/html/proofer/fixtures/links/file.foo
@@ -263,6 +267,7 @@ files:
263
267
  - spec/html/proofer/fixtures/links/head_link_href_empty.html
264
268
  - spec/html/proofer/fixtures/links/ignorableLinks.html
265
269
  - spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html
270
+ - spec/html/proofer/fixtures/links/invalid_mailto_link.html
266
271
  - spec/html/proofer/fixtures/links/javascript_link.html
267
272
  - spec/html/proofer/fixtures/links/linkToFolder.html
268
273
  - spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html
@@ -339,13 +344,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
344
  version: '0'
340
345
  requirements: []
341
346
  rubyforge_project:
342
- rubygems_version: 2.2.2
347
+ rubygems_version: 2.2.3
343
348
  signing_key:
344
349
  specification_version: 4
345
350
  summary: A set of tests to validate your HTML output. These tests check if your image
346
351
  references are legitimate, if they have alt tags, if your internal links are working,
347
352
  and so on. It's intended to be an all-in-one checker for your documentation output.
348
353
  test_files:
354
+ - spec/html/proofer/checkable_spec.rb
349
355
  - spec/html/proofer/command_spec.rb
350
356
  - spec/html/proofer/favicon_spec.rb
351
357
  - spec/html/proofer/fixtures/favicon/favicon_absent.html
@@ -359,8 +365,10 @@ test_files:
359
365
  - spec/html/proofer/fixtures/html/invalid_tag.html
360
366
  - spec/html/proofer/fixtures/html/missing_closing_quotes.html
361
367
  - spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html
368
+ - spec/html/proofer/fixtures/html/svg_elements.html
362
369
  - spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html
363
370
  - spec/html/proofer/fixtures/html/unmatched_end_tag.html
371
+ - spec/html/proofer/fixtures/images/emptyImageAltText.html
364
372
  - spec/html/proofer/fixtures/images/existingImageExternal.html
365
373
  - spec/html/proofer/fixtures/images/gpl.png
366
374
  - spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
@@ -397,7 +405,7 @@ test_files:
397
405
  - spec/html/proofer/fixtures/links/broken_hash_with_query.html
398
406
  - spec/html/proofer/fixtures/links/checkSSLLinks.html
399
407
  - spec/html/proofer/fixtures/links/ensure_typhoeus_options.html
400
- - spec/html/proofer/fixtures/links/erstiebegrüßung.html
408
+ - spec/html/proofer/fixtures/links/erstiebegr%C3%BC%C3%9Fung.html
401
409
  - spec/html/proofer/fixtures/links/erstiebegrüßung.html
402
410
  - spec/html/proofer/fixtures/links/escape_pipes.html
403
411
  - spec/html/proofer/fixtures/links/file.foo
@@ -416,6 +424,7 @@ test_files:
416
424
  - spec/html/proofer/fixtures/links/head_link_href_empty.html
417
425
  - spec/html/proofer/fixtures/links/ignorableLinks.html
418
426
  - spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html
427
+ - spec/html/proofer/fixtures/links/invalid_mailto_link.html
419
428
  - spec/html/proofer/fixtures/links/javascript_link.html
420
429
  - spec/html/proofer/fixtures/links/linkToFolder.html
421
430
  - spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html