html-proofer 2.3.0 → 3.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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/bin/htmlproofer +85 -0
  3. data/lib/html-proofer/cache.rb +153 -0
  4. data/lib/html-proofer/check/favicon.rb +15 -0
  5. data/lib/html-proofer/check/html.rb +21 -0
  6. data/lib/html-proofer/check/images.rb +47 -0
  7. data/lib/html-proofer/check/links.rb +120 -0
  8. data/lib/html-proofer/check/scripts.rb +28 -0
  9. data/lib/html-proofer/check.rb +63 -0
  10. data/lib/html-proofer/configuration.rb +56 -0
  11. data/lib/html-proofer/element.rb +165 -0
  12. data/lib/{html/proofer/check_runner → html-proofer}/issue.rb +8 -10
  13. data/lib/html-proofer/log.rb +49 -0
  14. data/lib/html-proofer/runner.rb +160 -0
  15. data/lib/html-proofer/url_validator.rb +218 -0
  16. data/lib/html-proofer/utils.rb +40 -0
  17. data/lib/html-proofer/version.rb +3 -0
  18. data/lib/html-proofer.rb +47 -0
  19. metadata +64 -289
  20. data/.gitignore +0 -26
  21. data/.travis.yml +0 -12
  22. data/Gemfile +0 -3
  23. data/LICENSE.txt +0 -22
  24. data/README.md +0 -265
  25. data/Rakefile +0 -21
  26. data/bin/htmlproof +0 -71
  27. data/html-proofer.gemspec +0 -31
  28. data/lib/html/proofer/check_runner.rb +0 -62
  29. data/lib/html/proofer/checkable.rb +0 -164
  30. data/lib/html/proofer/checks/favicon.rb +0 -21
  31. data/lib/html/proofer/checks/html.rb +0 -40
  32. data/lib/html/proofer/checks/images.rb +0 -57
  33. data/lib/html/proofer/checks/links.rb +0 -107
  34. data/lib/html/proofer/checks/scripts.rb +0 -39
  35. data/lib/html/proofer/log.rb +0 -38
  36. data/lib/html/proofer/url_validator.rb +0 -135
  37. data/lib/html/proofer/utils.rb +0 -24
  38. data/lib/html/proofer/version.rb +0 -6
  39. data/lib/html/proofer.rb +0 -189
  40. data/script/bootstrap +0 -5
  41. data/spec/html/proofer/checkable_spec.rb +0 -47
  42. data/spec/html/proofer/command_spec.rb +0 -88
  43. data/spec/html/proofer/favicon_spec.rb +0 -47
  44. data/spec/html/proofer/fixtures/favicon/favicon_absent.html +0 -4
  45. data/spec/html/proofer/fixtures/favicon/favicon_absent_apple.html +0 -7
  46. data/spec/html/proofer/fixtures/favicon/favicon_broken.html +0 -7
  47. data/spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html +0 -7
  48. data/spec/html/proofer/fixtures/favicon/favicon_present.html +0 -7
  49. data/spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html +0 -7
  50. data/spec/html/proofer/fixtures/html/div_inside_head.html +0 -6
  51. data/spec/html/proofer/fixtures/html/html5_tags.html +0 -9
  52. data/spec/html/proofer/fixtures/html/invalid_tag.html +0 -3
  53. data/spec/html/proofer/fixtures/html/missing_closing_quotes.html +0 -5
  54. data/spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html +0 -7
  55. data/spec/html/proofer/fixtures/html/svg_elements.html +0 -729
  56. data/spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html +0 -4
  57. data/spec/html/proofer/fixtures/html/unmatched_end_tag.html +0 -5
  58. data/spec/html/proofer/fixtures/images/emptyImageAltText.html +0 -10
  59. data/spec/html/proofer/fixtures/images/existingImageExternal.html +0 -9
  60. data/spec/html/proofer/fixtures/images/gpl.png +0 -0
  61. data/spec/html/proofer/fixtures/images/ignorableAltViaOptions.html +0 -13
  62. data/spec/html/proofer/fixtures/images/ignorableImages.html +0 -10
  63. data/spec/html/proofer/fixtures/images/ignoreAltButNotLink.html +0 -13
  64. data/spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html +0 -9
  65. data/spec/html/proofer/fixtures/images/image_missing_protocol_valid.html +0 -9
  66. data/spec/html/proofer/fixtures/images/missingImageAlt.html +0 -9
  67. data/spec/html/proofer/fixtures/images/missingImageAltText.html +0 -9
  68. data/spec/html/proofer/fixtures/images/missingImageExternal.html +0 -9
  69. data/spec/html/proofer/fixtures/images/missingImageInternal.html +0 -9
  70. data/spec/html/proofer/fixtures/images/missingImageSrc.html +0 -9
  71. data/spec/html/proofer/fixtures/images/relativeToSelf.html +0 -2
  72. data/spec/html/proofer/fixtures/images/rootRelativeImages.html +0 -2
  73. data/spec/html/proofer/fixtures/images/srcSetCheck.html +0 -7
  74. data/spec/html/proofer/fixtures/images/srcSetIgnorable.html +0 -13
  75. data/spec/html/proofer/fixtures/images/srcSetMissingAlt.html +0 -7
  76. data/spec/html/proofer/fixtures/images/srcSetMissingImage.html +0 -7
  77. data/spec/html/proofer/fixtures/images/terribleImageName.html +0 -9
  78. data/spec/html/proofer/fixtures/images/workingDataURIImage.html +0 -3
  79. data/spec/html/proofer/fixtures/links/_site/folder.html/index.html +0 -1
  80. data/spec/html/proofer/fixtures/links/anchors_in_pre.html +0 -12
  81. data/spec/html/proofer/fixtures/links/attributeWithDash.html +0 -8
  82. data/spec/html/proofer/fixtures/links/blank_mailto_link.html +0 -9
  83. data/spec/html/proofer/fixtures/links/blank_tel_link.html +0 -9
  84. data/spec/html/proofer/fixtures/links/brokenHashExternal.html +0 -11
  85. data/spec/html/proofer/fixtures/links/brokenHashInternal.html +0 -14
  86. data/spec/html/proofer/fixtures/links/brokenHashOnTheWeb.html +0 -2
  87. data/spec/html/proofer/fixtures/links/brokenInternalLink.html +0 -0
  88. data/spec/html/proofer/fixtures/links/brokenLinkExternal.html +0 -11
  89. data/spec/html/proofer/fixtures/links/brokenLinkInternal.html +0 -10
  90. data/spec/html/proofer/fixtures/links/brokenLinkWithNumber.html +0 -8
  91. data/spec/html/proofer/fixtures/links/brokenUnixLinks.html +0 -5
  92. data/spec/html/proofer/fixtures/links/broken_hash_with_query.html +0 -9
  93. data/spec/html/proofer/fixtures/links/checkSSLLinks.html +0 -1
  94. data/spec/html/proofer/fixtures/links/ensure_typhoeus_options.html +0 -1
  95. data/spec/html/proofer/fixtures/links/erstiebegr%C3%BC%C3%9Fung.html +0 -0
  96. data/spec/html/proofer/fixtures/links/erstiebegr/303/274/303/237ung.html +0 -0
  97. data/spec/html/proofer/fixtures/links/escape_pipes.html +0 -9
  98. data/spec/html/proofer/fixtures/links/file.foo +0 -11
  99. data/spec/html/proofer/fixtures/links/folder/anchorLink.html +0 -0
  100. data/spec/html/proofer/fixtures/links/folder/assets/barrel.png +0 -0
  101. data/spec/html/proofer/fixtures/links/folder/index.html +0 -0
  102. data/spec/html/proofer/fixtures/links/folder/multiples/catalog/file.html +0 -8
  103. data/spec/html/proofer/fixtures/links/folder/multiples/javadoc/file.html +0 -8
  104. data/spec/html/proofer/fixtures/links/folder/relativeImage.html +0 -2
  105. data/spec/html/proofer/fixtures/links/folder-php/index.php +0 -2
  106. data/spec/html/proofer/fixtures/links/githubHash.html +0 -1
  107. data/spec/html/proofer/fixtures/links/gpl.png +0 -0
  108. data/spec/html/proofer/fixtures/links/hashReferringToSelf.html +0 -44
  109. data/spec/html/proofer/fixtures/links/head_link_href.html +0 -7
  110. data/spec/html/proofer/fixtures/links/head_link_href_absent.html +0 -7
  111. data/spec/html/proofer/fixtures/links/head_link_href_empty.html +0 -7
  112. data/spec/html/proofer/fixtures/links/ignorableLinks.html +0 -13
  113. data/spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html +0 -13
  114. data/spec/html/proofer/fixtures/links/invalid_mailto_link.html +0 -9
  115. data/spec/html/proofer/fixtures/links/javascript_link.html +0 -9
  116. data/spec/html/proofer/fixtures/links/linkToFolder.html +0 -9
  117. data/spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html +0 -9
  118. data/spec/html/proofer/fixtures/links/linkWithHttps.html +0 -9
  119. data/spec/html/proofer/fixtures/links/linkWithRedirect.html +0 -12
  120. data/spec/html/proofer/fixtures/links/link_directory_without_slash.html +0 -1
  121. data/spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html +0 -9
  122. data/spec/html/proofer/fixtures/links/link_missing_protocol_valid.html +0 -9
  123. data/spec/html/proofer/fixtures/links/link_pointing_to_directory.html +0 -1
  124. data/spec/html/proofer/fixtures/links/links_in_pre.html +0 -13
  125. data/spec/html/proofer/fixtures/links/mailto_link.html +0 -9
  126. data/spec/html/proofer/fixtures/links/missingLinkHref.html +0 -9
  127. data/spec/html/proofer/fixtures/links/multipleProblems.html +0 -11
  128. data/spec/html/proofer/fixtures/links/nodupe.html +0 -1
  129. data/spec/html/proofer/fixtures/links/non_standard_characters.html +0 -10
  130. data/spec/html/proofer/fixtures/links/notarealhash.html +0 -0
  131. data/spec/html/proofer/fixtures/links/other_protocols.html +0 -4
  132. data/spec/html/proofer/fixtures/links/placeholder_with_empty_id.html +0 -1
  133. data/spec/html/proofer/fixtures/links/placeholder_with_id.html +0 -1
  134. data/spec/html/proofer/fixtures/links/placeholder_with_name.html +0 -1
  135. data/spec/html/proofer/fixtures/links/redirected_error.html +0 -1
  136. data/spec/html/proofer/fixtures/links/relativeLinks.html +0 -4
  137. data/spec/html/proofer/fixtures/links/rootLink/folder/index.html +0 -1
  138. data/spec/html/proofer/fixtures/links/rootLink/index.html +0 -1
  139. data/spec/html/proofer/fixtures/links/rootLink/rootLink.html +0 -9
  140. data/spec/html/proofer/fixtures/links/tel_link.html +0 -9
  141. data/spec/html/proofer/fixtures/links/urlencoded-href.html +0 -2
  142. data/spec/html/proofer/fixtures/links/utf8Link.html +0 -2
  143. data/spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png +0 -0
  144. data/spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg +0 -0
  145. data/spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg +0 -0
  146. data/spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg +0 -0
  147. data/spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html +0 -5
  148. data/spec/html/proofer/fixtures/resources/gpl.png +0 -0
  149. data/spec/html/proofer/fixtures/scripts/ignorableLinksViaOptions.html +0 -4
  150. data/spec/html/proofer/fixtures/scripts/script.js +0 -1
  151. data/spec/html/proofer/fixtures/scripts/script_broken_external.html +0 -9
  152. data/spec/html/proofer/fixtures/scripts/script_content.html +0 -9
  153. data/spec/html/proofer/fixtures/scripts/script_content_absent.html +0 -9
  154. data/spec/html/proofer/fixtures/scripts/script_in_pre.html +0 -5
  155. data/spec/html/proofer/fixtures/scripts/script_missing_internal.html +0 -9
  156. data/spec/html/proofer/fixtures/scripts/script_valid_internal.html +0 -9
  157. data/spec/html/proofer/fixtures/sorting/issue/broken_image_one.html +0 -1
  158. data/spec/html/proofer/fixtures/sorting/issue/broken_image_two.html +0 -4
  159. data/spec/html/proofer/fixtures/sorting/path/multiple_issues.html +0 -11
  160. data/spec/html/proofer/fixtures/sorting/path/single_issue.html +0 -1
  161. data/spec/html/proofer/fixtures/sorting/status/a_404.html +0 -1
  162. data/spec/html/proofer/fixtures/sorting/status/broken_link.html +0 -3
  163. data/spec/html/proofer/fixtures/sorting/status/missing_redirect.html +0 -1
  164. data/spec/html/proofer/fixtures/utils/lang-jp.html +0 -1
  165. data/spec/html/proofer/html_spec.rb +0 -57
  166. data/spec/html/proofer/images_spec.rb +0 -147
  167. data/spec/html/proofer/links_spec.rb +0 -364
  168. data/spec/html/proofer/scripts_spec.rb +0 -47
  169. data/spec/html/proofer/utils_spec.rb +0 -14
  170. data/spec/html/proofer_spec.rb +0 -122
  171. data/spec/spec_helper.rb +0 -52
@@ -1,13 +0,0 @@
1
-
2
- <pre>
3
-
4
- <link rel="icon" href="">
5
- </pre>
6
-
7
-
8
- <code>
9
-
10
-
11
- <link rel="icon" href="">
12
-
13
- </code>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="mailto:whatever@whoever.com">Mail me</a>.
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="">No link, man</a></p>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,11 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="http://www.asdo3IRJ395295jsingrkrg4.com" data-proofer-ignore="true">broken link!</a>
6
-
7
- <a href="#anadaasdadsadschor">Anchor relative to nothing</a>
8
-
9
- </body>
10
-
11
- </html>
@@ -1 +0,0 @@
1
- <a href="https://help.github.com/articlezzz">add ssh</a>
@@ -1,10 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="http://ben.balter.com/2014/10/08/why-government-contractors-should-%3C3-open-source/">We &lt;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>
File without changes
@@ -1,4 +0,0 @@
1
- <a href="git://github.com/mono/mono">Git</a>
2
- <a href="ftp://ftp.example.com">FTP</a>
3
- <a href="irc://irc.gimp.org/mono">IRC</a>
4
- <a href="svn://svn.example.com">SVN</a>
@@ -1 +0,0 @@
1
- <a id="placeholder"></a>
@@ -1 +0,0 @@
1
- <a name="placeholder"></a>
@@ -1 +0,0 @@
1
- <a href="http://asia.cnet.com/blogs/geekonomics/post.htm?id=63009224">not real</a>
@@ -1,4 +0,0 @@
1
- <a href="/anchors_in_pre.html">Relative to root</a>
2
- <a href="anchors_in_pre.html">Relative to self</a>
3
- <a href="folder/">Folder relative to self</a>
4
- <a href="anchors_in_pre.html#anchor">Anchor relative to self</a>
@@ -1 +0,0 @@
1
- Here I am.
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="/">I am root.</a></p>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="tel:441234567,88">+44-1234-567 ext.88</a>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,2 +0,0 @@
1
- <a href="erstiebegr%C3%BC%C3%9Fung.html">Erstiebegrüßung</a>
2
- <a href="erstiebegrüßung.html">Erstiebegrüßung</a>
@@ -1,2 +0,0 @@
1
- <a href="http://ben.balter.com/2014/09/29/source-disclosed-≠-open-source/">utf8</a>
2
- <a href="http://ben.balter.com/2014/09/29/source-disclosed-%E2%89%A0-open-source/">another utf8</a>
@@ -1,5 +0,0 @@
1
- <img src="assets/pro-git.jpg" alt="Pro Git">
2
-
3
- <img src="assets/getting-good-with-git.jpg" alt="Getting Good with Git">
4
-
5
- <img src="assets/version-control-with-git.jpg" alt="Version Control with Git, 2nd Edition">
@@ -1,4 +0,0 @@
1
- <html>
2
- <head>
3
- <script src="/assets/main.js"></script>
4
- <body>
@@ -1 +0,0 @@
1
- var x = 1;
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <script src="http://www.asdo3IRJ395295jsingrkrg4.com/asdo3IRJ.js"></script>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <script>var x = 1;</script>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <script></script>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,5 +0,0 @@
1
- <pre lang="html"><code><script src="https://embed.github.com/view/geojson/<username>/<repo>/<ref>/<path_to_file>"></script>
2
- </code></pre>
3
-
4
- <code><script src="https://embed.github.com/view/geojson/<username>/<repo>/<ref>/<path_to_file>"></script>
5
- </code>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <script src="doesnotexist.js"></script>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <script src="script.js"></script>
6
-
7
- </body>
8
-
9
- </html>
@@ -1 +0,0 @@
1
- <img src="./gpl.png" />
@@ -1,4 +0,0 @@
1
- <img src="./gpl.png" />
2
-
3
-
4
- <img alt="An existing image" src="NOT_AN_IMAGE" />
@@ -1,11 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="tel:">Tel me</a>
6
-
7
- <img src="gpl.png"/>Image.
8
-
9
- </body>
10
-
11
- </html>
@@ -1 +0,0 @@
1
- <img src="./Screen Shot 2012-08-09 at 7.51.18 AM.png" alt="textbox"/>
@@ -1 +0,0 @@
1
- <img alt="An existing image" src="//upload.wikimedia.org/wikipedia/en/thumb/not_here.png" />
@@ -1,3 +0,0 @@
1
- <img alt="An existing image" src="//upload.wikimedia.org/wikipedia/en/thumb/fooooof.png" />
2
-
3
- <a href="nowhere.fooof">nope</a>
@@ -1 +0,0 @@
1
- <a href="https://help.github.com/changing-author-info/">This is another redirect.</a>
@@ -1 +0,0 @@
1
- <html lang="jp">
@@ -1,57 +0,0 @@
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
- proofer = run_proofer(html)
7
- expect(proofer.failed_tests).to eq []
8
- end
9
-
10
- it "doesn't fail for html5 tags" do
11
- html = "#{FIXTURES_DIR}/html/html5_tags.html"
12
- proofer = run_proofer(html, { :check_html => true })
13
- expect(proofer.failed_tests).to eq []
14
- end
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
-
22
- it 'fails for an invalid tag' do
23
- html = "#{FIXTURES_DIR}/html/invalid_tag.html"
24
- proofer = run_proofer(html, { :check_html => true })
25
- expect(proofer.failed_tests.first).to match(/Tag myfancytag invalid/)
26
- end
27
-
28
- it 'fails for an unmatched end tag' do
29
- html = "#{FIXTURES_DIR}/html/unmatched_end_tag.html"
30
- proofer = run_proofer(html, { :check_html => true })
31
- expect(proofer.failed_tests.first).to match(/Unexpected end tag : div/)
32
- end
33
-
34
- it 'fails for an unescaped ampersand in attribute' do
35
- html = "#{FIXTURES_DIR}/html/unescaped_ampersand_in_attribute.html"
36
- proofer = run_proofer(html, { :check_html => true })
37
- expect(proofer.failed_tests.first).to match(/htmlParseEntityRef: expecting ';'/)
38
- end
39
-
40
- it 'fails for mismatch between opening and ending tag' do
41
- html = "#{FIXTURES_DIR}/html/opening_and_ending_tag_mismatch.html"
42
- proofer = run_proofer(html, { :check_html => true })
43
- expect(proofer.failed_tests.first).to match(/Opening and ending tag mismatch: p and strong/)
44
- end
45
-
46
- it 'fails for div inside head' do
47
- html = "#{FIXTURES_DIR}/html/div_inside_head.html"
48
- proofer = run_proofer(html, { :check_html => true })
49
- expect(proofer.failed_tests.first).to match(/Unexpected end tag : head/)
50
- end
51
-
52
- it 'fails for missing closing quotation mark in href' do
53
- html = "#{FIXTURES_DIR}/html/missing_closing_quotes.html"
54
- proofer = run_proofer(html, { :check_html => true })
55
- expect(proofer.failed_tests.to_s).to match(/Couldn't find end of Start Tag a/)
56
- end
57
- end
@@ -1,147 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Images test' do
4
- it 'passes for existing external images' do
5
- externalImageFilepath = "#{FIXTURES_DIR}/images/existingImageExternal.html"
6
- proofer = run_proofer(externalImageFilepath)
7
- expect(proofer.failed_tests).to eq []
8
- end
9
-
10
- it 'fails for image without alt attribute' do
11
- missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
12
- proofer = run_proofer(missingAltFilepath)
13
- expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
14
- end
15
-
16
- it 'fails for image with an empty alt attribute' do
17
- missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAltText.html"
18
- proofer = run_proofer(missingAltFilepath)
19
- expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
20
- end
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
-
35
- it 'fails for missing external images' do
36
- externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
37
- proofer = run_proofer(externalImageFilepath)
38
- expect(proofer.failed_tests.first).to match(/failed: 0 Couldn't resolve host/)
39
- end
40
-
41
- it 'fails for missing internal images' do
42
- internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
43
- proofer = run_proofer(internalImageFilepath)
44
- expect(proofer.failed_tests.first).to match(/doesnotexist.png does not exist/)
45
- end
46
-
47
- it 'fails for image with no src' do
48
- imageSrcFilepath = "#{FIXTURES_DIR}/images/missingImageSrc.html"
49
- proofer = run_proofer(imageSrcFilepath)
50
- expect(proofer.failed_tests.first).to match(/image has no src or srcset attribute/)
51
- end
52
-
53
- it 'fails for image with default mac filename' do
54
- terribleImageName = "#{FIXTURES_DIR}/images/terribleImageName.html"
55
- proofer = run_proofer(terribleImageName)
56
- expect(proofer.failed_tests.first).to match(/image has a terrible filename/)
57
- end
58
-
59
- it 'ignores images marked as ignore data-proofer-ignore' do
60
- ignorableImages = "#{FIXTURES_DIR}/images/ignorableImages.html"
61
- proofer = run_proofer(ignorableImages)
62
- expect(proofer.failed_tests).to eq []
63
- end
64
-
65
- it 'properly checks relative images' do
66
- relativeImages = "#{FIXTURES_DIR}/images/rootRelativeImages.html"
67
- proofer = run_proofer(relativeImages)
68
- expect(proofer.failed_tests).to eq []
69
-
70
- relativeImages = "#{FIXTURES_DIR}/resources/books/nestedRelativeImages.html"
71
- proofer = run_proofer(relativeImages)
72
- expect(proofer.failed_tests).to eq []
73
- end
74
-
75
- it 'properly ignores data URI images' do
76
- dataURIImage = "#{FIXTURES_DIR}/images/workingDataURIImage.html"
77
- proofer = run_proofer(dataURIImage)
78
- expect(proofer.failed_tests).to eq []
79
- end
80
-
81
- it 'works for valid images missing the protocol' do
82
- missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
83
- proofer = run_proofer(missingProtocolLink)
84
- expect(proofer.failed_tests).to eq []
85
- end
86
-
87
- it 'fails for invalid images missing the protocol' do
88
- missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
89
- proofer = run_proofer(missingProtocolLink)
90
- expect(proofer.failed_tests.first).to match(/404 No error/)
91
- end
92
-
93
- it 'properly checks relative links' do
94
- relativeLinks = "#{FIXTURES_DIR}/images/relativeToSelf.html"
95
- proofer = run_proofer(relativeLinks)
96
- expect(proofer.failed_tests).to eq []
97
- end
98
-
99
- it 'properly ignores missing alt tags when asked' do
100
- ignorableLinks = "#{FIXTURES_DIR}/images/ignorableAltViaOptions.html"
101
- proofer = run_proofer(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]})
102
- expect(proofer.failed_tests).to eq []
103
- end
104
-
105
- it 'properly ignores missing alt tags, but not all URLs, when asked' do
106
- ignorableLinks = "#{FIXTURES_DIR}/images/ignoreAltButNotLink.html"
107
- proofer = run_proofer(ignorableLinks, {:alt_ignore => [/.*/]})
108
- expect(proofer.failed_tests.first).to match(/Couldn't resolve host name/)
109
- expect(proofer.failed_tests.first).to_not match /does not have an alt attribute/
110
- end
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
-
124
- it 'works for images with a srcset' do
125
- srcSetCheck = "#{FIXTURES_DIR}/images/srcSetCheck.html"
126
- proofer = run_proofer(srcSetCheck)
127
- expect(proofer.failed_tests).to eq []
128
- end
129
-
130
- it 'fails for images with a srcset but missing alt' do
131
- srcSetMissingAlt = "#{FIXTURES_DIR}/images/srcSetMissingAlt.html"
132
- proofer = run_proofer(srcSetMissingAlt)
133
- expect(proofer.failed_tests.first).to match(/image gpl.png does not have an alt attribute/)
134
- end
135
-
136
- it 'fails for images with an alt but missing src or srcset' do
137
- srcSetMissingAlt = "#{FIXTURES_DIR}/images/srcSetMissingImage.html"
138
- proofer = run_proofer(srcSetMissingAlt)
139
- expect(proofer.failed_tests.first).to match(/internal image notreal.png does not exist/)
140
- end
141
-
142
- it 'properly ignores missing alt tags when asked for srcset' do
143
- ignorableLinks = "#{FIXTURES_DIR}/images/srcSetIgnorable.html"
144
- proofer = run_proofer(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]})
145
- expect(proofer.failed_tests).to eq []
146
- end
147
- end