html-proofer 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html/proofer/checks/links.rb +1 -1
  3. metadata +5 -168
  4. data/.gitignore +0 -26
  5. data/.travis.yml +0 -6
  6. data/Gemfile +0 -3
  7. data/LICENSE.txt +0 -22
  8. data/README.md +0 -177
  9. data/Rakefile +0 -8
  10. data/html-proofer.gemspec +0 -28
  11. data/spec/html/proofer/favicon_spec.rb +0 -46
  12. data/spec/html/proofer/fixtures/favicon/favicon_absent.html +0 -4
  13. data/spec/html/proofer/fixtures/favicon/favicon_absent_apple.html +0 -7
  14. data/spec/html/proofer/fixtures/favicon/favicon_broken.html +0 -7
  15. data/spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html +0 -7
  16. data/spec/html/proofer/fixtures/favicon/favicon_present.html +0 -7
  17. data/spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html +0 -7
  18. data/spec/html/proofer/fixtures/images/existingImageExternal.html +0 -9
  19. data/spec/html/proofer/fixtures/images/gpl.png +0 -0
  20. data/spec/html/proofer/fixtures/images/ignorableAltViaOptions.html +0 -13
  21. data/spec/html/proofer/fixtures/images/ignorableImages.html +0 -10
  22. data/spec/html/proofer/fixtures/images/ignoreAltButNotLink.html +0 -13
  23. data/spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html +0 -9
  24. data/spec/html/proofer/fixtures/images/image_missing_protocol_valid.html +0 -9
  25. data/spec/html/proofer/fixtures/images/missingImageAlt.html +0 -9
  26. data/spec/html/proofer/fixtures/images/missingImageAltText.html +0 -9
  27. data/spec/html/proofer/fixtures/images/missingImageExternal.html +0 -9
  28. data/spec/html/proofer/fixtures/images/missingImageInternal.html +0 -9
  29. data/spec/html/proofer/fixtures/images/missingImageSrc.html +0 -9
  30. data/spec/html/proofer/fixtures/images/relativeToSelf.html +0 -2
  31. data/spec/html/proofer/fixtures/images/rootRelativeImages.html +0 -2
  32. data/spec/html/proofer/fixtures/images/terribleImageName.html +0 -9
  33. data/spec/html/proofer/fixtures/images/workingDataURIImage.html +0 -3
  34. data/spec/html/proofer/fixtures/links/anchors_in_pre.html +0 -12
  35. data/spec/html/proofer/fixtures/links/blank_mailto_link.html +0 -9
  36. data/spec/html/proofer/fixtures/links/blank_tel_link.html +0 -9
  37. data/spec/html/proofer/fixtures/links/brokenHashExternal.html +0 -11
  38. data/spec/html/proofer/fixtures/links/brokenHashInternal.html +0 -14
  39. data/spec/html/proofer/fixtures/links/brokenInternalLink.html +0 -0
  40. data/spec/html/proofer/fixtures/links/brokenLinkExternal.html +0 -11
  41. data/spec/html/proofer/fixtures/links/brokenLinkInternal.html +0 -10
  42. data/spec/html/proofer/fixtures/links/brokenLinkWithNumber.html +0 -8
  43. data/spec/html/proofer/fixtures/links/checkSSLLinks.html +0 -1
  44. data/spec/html/proofer/fixtures/links/folder/anchorLink.html +0 -0
  45. data/spec/html/proofer/fixtures/links/folder/assets/barrel.png +0 -0
  46. data/spec/html/proofer/fixtures/links/folder/index.html +0 -0
  47. data/spec/html/proofer/fixtures/links/folder/relativeImage.html +0 -2
  48. data/spec/html/proofer/fixtures/links/gpl.png +0 -0
  49. data/spec/html/proofer/fixtures/links/head_link_href.html +0 -7
  50. data/spec/html/proofer/fixtures/links/head_link_href_absent.html +0 -7
  51. data/spec/html/proofer/fixtures/links/head_link_href_empty.html +0 -7
  52. data/spec/html/proofer/fixtures/links/ignorableLinks.html +0 -13
  53. data/spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html +0 -13
  54. data/spec/html/proofer/fixtures/links/index.html +0 -1
  55. data/spec/html/proofer/fixtures/links/javascript_link.html +0 -9
  56. data/spec/html/proofer/fixtures/links/linkToFolder.html +0 -9
  57. data/spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html +0 -9
  58. data/spec/html/proofer/fixtures/links/linkWithHttps.html +0 -9
  59. data/spec/html/proofer/fixtures/links/linkWithRedirect.html +0 -12
  60. data/spec/html/proofer/fixtures/links/link_directory_without_slash.html +0 -1
  61. data/spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html +0 -9
  62. data/spec/html/proofer/fixtures/links/link_missing_protocol_valid.html +0 -9
  63. data/spec/html/proofer/fixtures/links/links_in_pre.html +0 -13
  64. data/spec/html/proofer/fixtures/links/mailto_link.html +0 -9
  65. data/spec/html/proofer/fixtures/links/missingLinkHref.html +0 -9
  66. data/spec/html/proofer/fixtures/links/multipleProblems.html +0 -11
  67. data/spec/html/proofer/fixtures/links/notarealhash.html +0 -0
  68. data/spec/html/proofer/fixtures/links/relativeLinks.html +0 -4
  69. data/spec/html/proofer/fixtures/links/rootLink.html +0 -10
  70. data/spec/html/proofer/fixtures/links/tel_link.html +0 -9
  71. data/spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png +0 -0
  72. data/spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg +0 -0
  73. data/spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg +0 -0
  74. data/spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg +0 -0
  75. data/spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html +0 -5
  76. data/spec/html/proofer/fixtures/resources/gpl.png +0 -0
  77. data/spec/html/proofer/fixtures/scripts/script.js +0 -1
  78. data/spec/html/proofer/fixtures/scripts/script_broken_external.html +0 -9
  79. data/spec/html/proofer/fixtures/scripts/script_content.html +0 -9
  80. data/spec/html/proofer/fixtures/scripts/script_content_absent.html +0 -9
  81. data/spec/html/proofer/fixtures/scripts/script_in_pre.html +0 -5
  82. data/spec/html/proofer/fixtures/scripts/script_missing_internal.html +0 -9
  83. data/spec/html/proofer/fixtures/scripts/script_valid_internal.html +0 -9
  84. data/spec/html/proofer/images_spec.rb +0 -98
  85. data/spec/html/proofer/links_spec.rb +0 -192
  86. data/spec/html/proofer/scripts_spec.rb +0 -41
  87. data/spec/html/proofer_spec.rb +0 -12
  88. data/spec/spec_helper.rb +0 -30
@@ -1,13 +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" data-proofer-ignore=true>Anchor relative to nothing</a>
8
-
9
- <a href="../whaadadt.html" data-proofer-ignore>Relative to nothing</a>
10
-
11
- </body>
12
-
13
- </html>
@@ -1,13 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="http://www.asdo3IRJ395295jsingrkrg4.com">broken link!</a>
6
-
7
- <a href="#anadaasdadsadschor">Anchor relative to nothing</a>
8
-
9
- <a href="../whaadadt.html">Relative to nothing</a>
10
-
11
- </body>
12
-
13
- </html>
@@ -1 +0,0 @@
1
- <h1 id="anchor">root.</a>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="javascript:if(typeof WZXYxe58==typeof alert)WZXYxe58();(function(){var s=document.createElement('link');s.setAttribute('href','/static/css/dyslexia.css');s.setAttribute('rel','stylesheet');s.setAttribute('type','text/css');document.getElementsByTagName('head')[0].appendChild(s);})();">Click 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="folder/">A pretty permlaink!</a></p>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <a href="/articles/linkToFolder">A real file, but the href should change!</a>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="https://github.com/octocat/Spoon-Knife/issues">An HTTPS link!</a></p>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,12 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="http://github.github.com/github-flavored-markdown/">This is a redirect.</a>. </p>
6
-
7
- <p>Blah blah blah. <a href="https://help.github.com/changing-author-info/">This is another redirect.</a>. </p>
8
-
9
- <p>Blah blah blah. <a href="http://timclem.wordpress.com/2012/03/01/mind-the-end-of-your-line/">This is a third redirect.</a>. </p>
10
- </body>
11
-
12
- </html>
@@ -1 +0,0 @@
1
- <a href="folder">Folder</a>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="//fofofo.biz.woo">An unreal link!</a></p>
6
-
7
- </body>
8
-
9
- </html>
@@ -1,9 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="//github.com/octocat/Spoon-Knife/issues">An HTTPS link!</a></p>
6
-
7
- </body>
8
-
9
- </html>
@@ -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>
File without changes
@@ -1,4 +0,0 @@
1
- <a href="/index.html">Relative to root</a>
2
- <a href="index.html">Relative to self</a>
3
- <a href="folder/">Folder relative to self</a>
4
- <a href="index.html#anchor">Anchor relative to self</a>
@@ -1,10 +0,0 @@
1
- <html>
2
-
3
- <body>
4
-
5
- <p>Blah blah blah. <a href="/">I am root.</a></p>
6
- <p>Blah blah blah. <a href="/folder">I am relative to root.</a></p>
7
-
8
- </body>
9
-
10
- </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,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 +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,98 +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
- output = capture_stderr { HTML::Proofer.new(externalImageFilepath).run }
7
- output.should == ""
8
- end
9
-
10
- it "fails for image without alt attribute" do
11
- missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
12
- output = capture_stderr { HTML::Proofer.new(missingAltFilepath).run }
13
- output.should 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
- output = capture_stderr { HTML::Proofer.new(missingAltFilepath).run }
19
- output.should match /gpl.png does not have an alt attribute/
20
- end
21
-
22
- it "fails for missing external images" do
23
- externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
24
- output = capture_stderr { HTML::Proofer.new(externalImageFilepath).run }
25
- output.should match /External link http:\/\/www.whatthehell\/? failed: 0 Couldn't resolve host/
26
- end
27
-
28
- it "fails for missing internal images" do
29
- internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
30
- output = capture_stderr { HTML::Proofer.new(internalImageFilepath).run }
31
- output.should match /doesnotexist.png does not exist/
32
- end
33
-
34
- it "fails for image with no src" do
35
- imageSrcFilepath = "#{FIXTURES_DIR}/images/missingImageSrc.html"
36
- output = capture_stderr { HTML::Proofer.new(imageSrcFilepath).run }
37
- output.should match /image has no src attribute/
38
- end
39
-
40
- it "fails for image with default mac filename" do
41
- terribleImageName = "#{FIXTURES_DIR}/images/terribleImageName.html"
42
- output = capture_stderr { HTML::Proofer.new(terribleImageName).run }
43
- output.should match /image has a terrible filename/
44
- end
45
-
46
- it 'ignores images marked as ignore data-proofer-ignore' do
47
- ignorableImages = "#{FIXTURES_DIR}/images/ignorableImages.html"
48
- output = capture_stderr { HTML::Proofer.new(ignorableImages).run }
49
- output.should == ""
50
- end
51
-
52
- it 'properly checks relative images' do
53
- relativeImages = "#{FIXTURES_DIR}/images/rootRelativeImages.html"
54
- output = capture_stderr { HTML::Proofer.new(relativeImages).run }
55
- output.should == ""
56
-
57
- relativeImages = "#{FIXTURES_DIR}/resources/books/nestedRelativeImages.html"
58
- output = capture_stderr { HTML::Proofer.new(relativeImages).run }
59
- output.should == ""
60
- end
61
-
62
- it 'properly ignores data URI images' do
63
- dataURIImage = "#{FIXTURES_DIR}/images/workingDataURIImage.html"
64
- output = capture_stderr { HTML::Proofer.new(dataURIImage).run }
65
- output.should == ""
66
- end
67
-
68
- it "works for valid images missing the protocol" do
69
- missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
70
- output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
71
- output.should == ""
72
- end
73
-
74
- it "fails for invalid images missing the protocol" do
75
- missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
76
- output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
77
- output.should match /404 No error/
78
- end
79
-
80
- it 'properly checks relative links' do
81
- relativeLinks = "#{FIXTURES_DIR}/images/relativeToSelf.html"
82
- output = capture_stderr { HTML::Proofer.new(relativeLinks).run }
83
- output.should == ""
84
- end
85
-
86
- it 'properly ignores missing alt tags when asked' do
87
- ignorableLinks = "#{FIXTURES_DIR}/images/ignorableAltViaOptions.html"
88
- output = capture_stderr { HTML::Proofer.new(ignorableLinks, {:alt_ignore => [/wikimedia/, "gpl.png"]}).run }
89
- output.should == ""
90
- end
91
-
92
- it 'properly ignores missing alt tags, but not all URLs, when asked' do
93
- ignorableLinks = "#{FIXTURES_DIR}/images/ignoreAltButNotLink.html"
94
- output = capture_stderr { HTML::Proofer.new(ignorableLinks, {:alt_ignore => [/.*/]}).run }
95
- output.should match /Couldn't resolve host name/
96
- output.should_not match /does not have an alt attribute/
97
- end
98
- end
@@ -1,192 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Links test" do
4
-
5
- it "fails for broken external hash (even if the file exists)" do
6
- brokenHashExternalFilepath = "#{FIXTURES_DIR}/links/brokenHashExternal.html"
7
- output = capture_stderr { HTML::Proofer.new(brokenHashExternalFilepath).run }
8
- output.should match /linking to ..\/images\/missingImageAlt.html#asdfasfdkafl, but asdfasfdkafl does not exist/
9
- end
10
-
11
- it "fails for broken internal hash" do
12
- brokenHashInternalFilepath = "#{FIXTURES_DIR}/links/brokenHashInternal.html"
13
- output = capture_stderr { HTML::Proofer.new(brokenHashInternalFilepath).run }
14
- output.should match /linking to internal hash #noHash that does not exist/
15
- end
16
-
17
- it "fails for broken external links" do
18
- brokenLinkExternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkExternal.html"
19
- output = capture_stderr { HTML::Proofer.new(brokenLinkExternalFilepath).run }
20
- output.should match /External link http:\/\/www.asdo3IRJ395295jsingrkrg4.com\/? failed: 0 Couldn't resolve host name/
21
- end
22
-
23
- it "fails for broken internal links" do
24
- brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
25
- output = capture_stderr { HTML::Proofer.new(brokenLinkInternalFilepath).run }
26
- output.should match /internally linking to .\/notreal.html, which does not exist/
27
- end
28
-
29
- it "fails for link with no href" do
30
- missingLinkHrefFilepath = "#{FIXTURES_DIR}/links/missingLinkHref.html"
31
- output = capture_stderr { HTML::Proofer.new(missingLinkHrefFilepath).run }
32
- output.should match /link has no href attribute/
33
- end
34
-
35
- it "should follow redirects" do
36
- linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
37
- output = capture_stderr { HTML::Proofer.new(linkWithRedirectFilepath).run }
38
- output.should == ""
39
- end
40
-
41
- it "fails on redirects if not following" do
42
- options = { :followlocation => false }
43
- linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
44
- output = capture_stderr { HTML::Proofer.new(linkWithRedirectFilepath, options).run }
45
- output.should match /External link https:\/\/help.github.com\/changing-author-info\/ failed: 301 No error/
46
- end
47
-
48
- it "should understand https" do
49
- linkWithHttpsFilepath = "#{FIXTURES_DIR}/links/linkWithHttps.html"
50
- output = capture_stderr { HTML::Proofer.new(linkWithHttpsFilepath).run }
51
- output.should == ""
52
- end
53
-
54
- it "fails for broken hash links with status code numbers" do
55
- brokenLinkWithNumberFilepath = "#{FIXTURES_DIR}/links/brokenLinkWithNumber.html"
56
- output = capture_stderr { HTML::Proofer.new(brokenLinkWithNumberFilepath).run }
57
- output.should match /linking to internal hash #25-method-not-allowed that does not exist/
58
- end
59
-
60
- it 'properly resolves implicit /index.html in link paths' do
61
- linkToFolder = "#{FIXTURES_DIR}/links/linkToFolder.html"
62
- output = capture_stderr { HTML::Proofer.new(linkToFolder).run }
63
- output.should == ""
64
- end
65
-
66
- it 'properly checks links to root' do
67
- rootLink = "#{FIXTURES_DIR}/links/rootLink.html"
68
- output = capture_stderr { HTML::Proofer.new(rootLink).run }
69
- output.should == ""
70
- end
71
-
72
- it 'properly checks relative links' do
73
- relativeLinks = "#{FIXTURES_DIR}/links/relativeLinks.html"
74
- output = capture_stderr { HTML::Proofer.new(relativeLinks).run }
75
- output.should == ""
76
- end
77
-
78
- it 'properly checks ssl links' do
79
- checkSSLLinks = "#{FIXTURES_DIR}/links/checkSSLLinks.html"
80
- output = capture_stderr { HTML::Proofer.new(checkSSLLinks).run }
81
- output.should == ""
82
- end
83
-
84
- it 'ignores links marked as ignore data-proofer-ignore' do
85
- ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinks.html"
86
- output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
87
- output.should == ""
88
- end
89
-
90
- it 'ignores links via href_ignore' do
91
- ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinksViaOptions.html"
92
- output = capture_stderr { HTML::Proofer.new(ignorableLinks, {:href_ignore => [/^http:\/\//, /sdadsad/, "../whaadadt.html"]}).run }
93
- output.should == ""
94
- end
95
-
96
- it 'translates links via href_swap' do
97
- translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedViaHrefSwap.html"
98
- output = capture_stderr { HTML::Proofer.new(translatedLink, {:href_swap => { /\A\/articles\/([\w-]+)/ => "\\1.html" }}).run }
99
- output.should == ""
100
- end
101
-
102
- it 'finds a mix of broken and unbroken links' do
103
- multipleProblems = "#{FIXTURES_DIR}/links/multipleProblems.html"
104
- output = capture_stderr { HTML::Proofer.new(multipleProblems).run }
105
- output.should match /linking to internal hash #anadaasdadsadschor that does not exist/
106
- end
107
-
108
- it 'ignores valid mailto links' do
109
- ignorableLinks = "#{FIXTURES_DIR}/links/mailto_link.html"
110
- output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
111
- output.should == ""
112
- end
113
-
114
- it "fails for blank mailto links" do
115
- blankMailToLink = "#{FIXTURES_DIR}/links/blank_mailto_link.html"
116
- output = capture_stderr { HTML::Proofer.new(blankMailToLink).run }
117
- output.should match /mailto: is an invalid URL/
118
- end
119
-
120
- it 'ignores valid tel links' do
121
- ignorableLinks = "#{FIXTURES_DIR}/links/tel_link.html"
122
- output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
123
- output.should == ""
124
- end
125
-
126
- it "fails for blank tel links" do
127
- blankTelLink = "#{FIXTURES_DIR}/links/blank_tel_link.html"
128
- output = capture_stderr { HTML::Proofer.new(blankTelLink).run }
129
- output.should match /tel: is an invalid URL/
130
- end
131
-
132
- it 'ignores javascript links' do
133
- javascriptLink = "#{FIXTURES_DIR}/links/javascript_link.html"
134
- output = capture_stderr { HTML::Proofer.new(javascriptLink).run }
135
- output.should == ""
136
- end
137
-
138
- it "works for valid links missing the protocol" do
139
- missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_valid.html"
140
- output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
141
- output.should == ""
142
- end
143
-
144
- it "fails for invalid links missing the protocol" do
145
- missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_invalid.html"
146
- output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
147
- output.should match /Couldn't resolve host name/
148
- end
149
-
150
- it "works for valid href within link elements" do
151
- head_link = "#{FIXTURES_DIR}/links/head_link_href.html"
152
- output = capture_stderr { HTML::Proofer.new(head_link).run }
153
- output.should == ""
154
- end
155
-
156
- it "fails for empty href within link elements" do
157
- head_link = "#{FIXTURES_DIR}/links/head_link_href_empty.html"
158
- output = capture_stderr { HTML::Proofer.new(head_link).run }
159
- output.should match /link has no href attribute/
160
- end
161
-
162
- it "fails for absent href within link elements" do
163
- head_link = "#{FIXTURES_DIR}/links/head_link_href_absent.html"
164
- output = capture_stderr { HTML::Proofer.new(head_link).run }
165
- output.should match /link has no href attribute/
166
- end
167
-
168
- it "fails for internal linking to a directory without trailing slash" do
169
- options = { :followlocation => false }
170
- internal = "#{FIXTURES_DIR}/links/link_directory_without_slash.html"
171
- output = capture_stderr { HTML::Proofer.new(internal, options).run }
172
- output.should match /without trailing slash/
173
- end
174
-
175
- it "works for array of links" do
176
- options = { :as_link_array => true}
177
- output = capture_stderr { HTML::Proofer.new(["www.github.com", "foofoofoo.biz"], options).run }
178
- output.should match /foofoo.biz\/? failed: 0 Couldn't resolve host name/
179
- end
180
-
181
- it "works for broken anchors within pre" do
182
- anchor_pre = "#{FIXTURES_DIR}/links/anchors_in_pre.html"
183
- output = capture_stderr { HTML::Proofer.new(anchor_pre).run }
184
- output.should == ""
185
- end
186
-
187
- it "works for broken link within pre" do
188
- link_pre = "#{FIXTURES_DIR}/links/links_in_pre.html"
189
- output = capture_stderr { HTML::Proofer.new(link_pre).run }
190
- output.should == ""
191
- end
192
- end