html-proofer 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +26 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +177 -0
  7. data/Rakefile +8 -0
  8. data/html-proofer.gemspec +28 -0
  9. data/spec/html/proofer/favicon_spec.rb +46 -0
  10. data/spec/html/proofer/fixtures/favicon/favicon_absent.html +4 -0
  11. data/spec/html/proofer/fixtures/favicon/favicon_absent_apple.html +7 -0
  12. data/spec/html/proofer/fixtures/favicon/favicon_broken.html +7 -0
  13. data/spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html +7 -0
  14. data/spec/html/proofer/fixtures/favicon/favicon_present.html +7 -0
  15. data/spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html +7 -0
  16. data/spec/html/proofer/fixtures/images/existingImageExternal.html +9 -0
  17. data/spec/html/proofer/fixtures/images/gpl.png +0 -0
  18. data/spec/html/proofer/fixtures/images/ignorableAltViaOptions.html +13 -0
  19. data/spec/html/proofer/fixtures/images/ignorableImages.html +10 -0
  20. data/spec/html/proofer/fixtures/images/ignoreAltButNotLink.html +13 -0
  21. data/spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html +9 -0
  22. data/spec/html/proofer/fixtures/images/image_missing_protocol_valid.html +9 -0
  23. data/spec/html/proofer/fixtures/images/missingImageAlt.html +9 -0
  24. data/spec/html/proofer/fixtures/images/missingImageAltText.html +9 -0
  25. data/spec/html/proofer/fixtures/images/missingImageExternal.html +9 -0
  26. data/spec/html/proofer/fixtures/images/missingImageInternal.html +9 -0
  27. data/spec/html/proofer/fixtures/images/missingImageSrc.html +9 -0
  28. data/spec/html/proofer/fixtures/images/relativeToSelf.html +2 -0
  29. data/spec/html/proofer/fixtures/images/rootRelativeImages.html +2 -0
  30. data/spec/html/proofer/fixtures/images/terribleImageName.html +9 -0
  31. data/spec/html/proofer/fixtures/images/workingDataURIImage.html +3 -0
  32. data/spec/html/proofer/fixtures/links/anchors_in_pre.html +12 -0
  33. data/spec/html/proofer/fixtures/links/blank_mailto_link.html +9 -0
  34. data/spec/html/proofer/fixtures/links/blank_tel_link.html +9 -0
  35. data/spec/html/proofer/fixtures/links/brokenHashExternal.html +11 -0
  36. data/spec/html/proofer/fixtures/links/brokenHashInternal.html +14 -0
  37. data/spec/html/proofer/fixtures/links/brokenInternalLink.html +0 -0
  38. data/spec/html/proofer/fixtures/links/brokenLinkExternal.html +11 -0
  39. data/spec/html/proofer/fixtures/links/brokenLinkInternal.html +10 -0
  40. data/spec/html/proofer/fixtures/links/brokenLinkWithNumber.html +8 -0
  41. data/spec/html/proofer/fixtures/links/checkSSLLinks.html +1 -0
  42. data/spec/html/proofer/fixtures/links/folder/anchorLink.html +0 -0
  43. data/spec/html/proofer/fixtures/links/folder/assets/barrel.png +0 -0
  44. data/spec/html/proofer/fixtures/links/folder/index.html +0 -0
  45. data/spec/html/proofer/fixtures/links/folder/relativeImage.html +2 -0
  46. data/spec/html/proofer/fixtures/links/gpl.png +0 -0
  47. data/spec/html/proofer/fixtures/links/head_link_href.html +7 -0
  48. data/spec/html/proofer/fixtures/links/head_link_href_absent.html +7 -0
  49. data/spec/html/proofer/fixtures/links/head_link_href_empty.html +7 -0
  50. data/spec/html/proofer/fixtures/links/ignorableLinks.html +13 -0
  51. data/spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html +13 -0
  52. data/spec/html/proofer/fixtures/links/index.html +1 -0
  53. data/spec/html/proofer/fixtures/links/javascript_link.html +9 -0
  54. data/spec/html/proofer/fixtures/links/linkToFolder.html +9 -0
  55. data/spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html +9 -0
  56. data/spec/html/proofer/fixtures/links/linkWithHttps.html +9 -0
  57. data/spec/html/proofer/fixtures/links/linkWithRedirect.html +12 -0
  58. data/spec/html/proofer/fixtures/links/link_directory_without_slash.html +1 -0
  59. data/spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html +9 -0
  60. data/spec/html/proofer/fixtures/links/link_missing_protocol_valid.html +9 -0
  61. data/spec/html/proofer/fixtures/links/links_in_pre.html +13 -0
  62. data/spec/html/proofer/fixtures/links/mailto_link.html +9 -0
  63. data/spec/html/proofer/fixtures/links/missingLinkHref.html +9 -0
  64. data/spec/html/proofer/fixtures/links/multipleProblems.html +11 -0
  65. data/spec/html/proofer/fixtures/links/notarealhash.html +0 -0
  66. data/spec/html/proofer/fixtures/links/relativeLinks.html +4 -0
  67. data/spec/html/proofer/fixtures/links/rootLink.html +10 -0
  68. data/spec/html/proofer/fixtures/links/tel_link.html +9 -0
  69. data/spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png +0 -0
  70. data/spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg +0 -0
  71. data/spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg +0 -0
  72. data/spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg +0 -0
  73. data/spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html +5 -0
  74. data/spec/html/proofer/fixtures/resources/gpl.png +0 -0
  75. data/spec/html/proofer/fixtures/scripts/script.js +1 -0
  76. data/spec/html/proofer/fixtures/scripts/script_broken_external.html +9 -0
  77. data/spec/html/proofer/fixtures/scripts/script_content.html +9 -0
  78. data/spec/html/proofer/fixtures/scripts/script_content_absent.html +9 -0
  79. data/spec/html/proofer/fixtures/scripts/script_in_pre.html +5 -0
  80. data/spec/html/proofer/fixtures/scripts/script_missing_internal.html +9 -0
  81. data/spec/html/proofer/fixtures/scripts/script_valid_internal.html +9 -0
  82. data/spec/html/proofer/images_spec.rb +98 -0
  83. data/spec/html/proofer/links_spec.rb +192 -0
  84. data/spec/html/proofer/scripts_spec.rb +41 -0
  85. data/spec/html/proofer_spec.rb +12 -0
  86. data/spec/spec_helper.rb +30 -0
  87. metadata +166 -3
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <script src="http://www.asdo3IRJ395295jsingrkrg4.com/asdo3IRJ.js"></script>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <script>var x = 1;</script>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <script></script>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,5 @@
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>
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <script src="doesnotexist.js"></script>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,9 @@
1
+ <html>
2
+
3
+ <body>
4
+
5
+ <script src="script.js"></script>
6
+
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,98 @@
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
@@ -0,0 +1,192 @@
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 /anchor 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 /anchor 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 /anchor 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
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe "Scripts test" do
4
+
5
+ it "fails for broken external src" do
6
+ file = "#{FIXTURES_DIR}/scripts/script_broken_external.html"
7
+ output = capture_stderr { HTML::Proofer.new(file).run }
8
+ output.should match /External link http:\/\/www.asdo3IRJ395295jsingrkrg4.com\/asdo3IRJ.js? failed: 0 Couldn't resolve host name/
9
+ end
10
+
11
+ it "works for valid internal src" do
12
+ file = "#{FIXTURES_DIR}/scripts/script_valid_internal.html"
13
+ output = capture_stderr { HTML::Proofer.new(file).run }
14
+ output.should == ""
15
+ end
16
+
17
+ it "fails for missing internal src" do
18
+ file = "#{FIXTURES_DIR}/scripts/script_missing_internal.html"
19
+ output = capture_stderr { HTML::Proofer.new(file).run }
20
+ output.should match /doesnotexist.js does not exist/
21
+ end
22
+
23
+ it "works for present content" do
24
+ file = "#{FIXTURES_DIR}/scripts/script_content.html"
25
+ output = capture_stderr { HTML::Proofer.new(file).run }
26
+ output.should == ""
27
+ end
28
+
29
+ it "fails for absent content" do
30
+ file = "#{FIXTURES_DIR}/scripts/script_content_absent.html"
31
+ output = capture_stderr { HTML::Proofer.new(file).run }
32
+ output.should match /script is empty and has no src attribute/
33
+ end
34
+
35
+ it "works for broken script within pre" do
36
+ script_pre = "#{FIXTURES_DIR}/scripts/script_in_pre.html"
37
+ output = capture_stderr { HTML::Proofer.new(script_pre).run }
38
+ output.should == ""
39
+ end
40
+
41
+ end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe HTML::Proofer do
4
+ describe "#failed_tests" do
5
+ it "is a list of the formatted errors" do
6
+ brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
7
+ proofer = HTML::Proofer.new(brokenLinkInternalFilepath)
8
+ capture_stderr { proofer.run }
9
+ proofer.failed_tests.should eq(["\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./notreal.html, which does not exist", "\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./missingImageAlt.html, which does not exist"])
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ require 'bundler/setup'
2
+ require_relative "../lib/html/proofer"
3
+
4
+ FIXTURES_DIR = "spec/html/proofer/fixtures"
5
+
6
+ RSpec.configure do |config|
7
+ # Use color in STDOUT
8
+ config.color_enabled = true
9
+
10
+ # Use color not only in STDOUT but also in pagers and files
11
+ config.tty = true
12
+
13
+ # Use the specified formatter
14
+ config.formatter = :documentation # :progress, :html, :textmate
15
+ end
16
+
17
+ def capture_stderr(&block)
18
+ original_stderr = $stderr
19
+ original_stdout = $stdout
20
+ $stderr = fake_err = StringIO.new
21
+ $stdout = fake_out = StringIO.new
22
+ begin
23
+ yield
24
+ rescue RuntimeError
25
+ ensure
26
+ $stderr = original_stderr
27
+ $stdout = original_stdout
28
+ end
29
+ fake_err.string
30
+ end
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: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -144,7 +144,14 @@ executables:
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
+ - ".gitignore"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
147
153
  - bin/htmlproof
154
+ - html-proofer.gemspec
148
155
  - lib/html/proofer.rb
149
156
  - lib/html/proofer/check.rb
150
157
  - lib/html/proofer/checkable.rb
@@ -153,6 +160,84 @@ files:
153
160
  - lib/html/proofer/checks/images.rb
154
161
  - lib/html/proofer/checks/links.rb
155
162
  - lib/html/proofer/checks/scripts.rb
163
+ - spec/html/proofer/favicon_spec.rb
164
+ - spec/html/proofer/fixtures/favicon/favicon_absent.html
165
+ - spec/html/proofer/fixtures/favicon/favicon_absent_apple.html
166
+ - spec/html/proofer/fixtures/favicon/favicon_broken.html
167
+ - spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html
168
+ - spec/html/proofer/fixtures/favicon/favicon_present.html
169
+ - spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html
170
+ - spec/html/proofer/fixtures/images/existingImageExternal.html
171
+ - spec/html/proofer/fixtures/images/gpl.png
172
+ - spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
173
+ - spec/html/proofer/fixtures/images/ignorableImages.html
174
+ - spec/html/proofer/fixtures/images/ignoreAltButNotLink.html
175
+ - spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html
176
+ - spec/html/proofer/fixtures/images/image_missing_protocol_valid.html
177
+ - spec/html/proofer/fixtures/images/missingImageAlt.html
178
+ - spec/html/proofer/fixtures/images/missingImageAltText.html
179
+ - spec/html/proofer/fixtures/images/missingImageExternal.html
180
+ - spec/html/proofer/fixtures/images/missingImageInternal.html
181
+ - spec/html/proofer/fixtures/images/missingImageSrc.html
182
+ - spec/html/proofer/fixtures/images/relativeToSelf.html
183
+ - spec/html/proofer/fixtures/images/rootRelativeImages.html
184
+ - spec/html/proofer/fixtures/images/terribleImageName.html
185
+ - spec/html/proofer/fixtures/images/workingDataURIImage.html
186
+ - spec/html/proofer/fixtures/links/anchors_in_pre.html
187
+ - spec/html/proofer/fixtures/links/blank_mailto_link.html
188
+ - spec/html/proofer/fixtures/links/blank_tel_link.html
189
+ - spec/html/proofer/fixtures/links/brokenHashExternal.html
190
+ - spec/html/proofer/fixtures/links/brokenHashInternal.html
191
+ - spec/html/proofer/fixtures/links/brokenInternalLink.html
192
+ - spec/html/proofer/fixtures/links/brokenLinkExternal.html
193
+ - spec/html/proofer/fixtures/links/brokenLinkInternal.html
194
+ - spec/html/proofer/fixtures/links/brokenLinkWithNumber.html
195
+ - spec/html/proofer/fixtures/links/checkSSLLinks.html
196
+ - spec/html/proofer/fixtures/links/folder/anchorLink.html
197
+ - spec/html/proofer/fixtures/links/folder/assets/barrel.png
198
+ - spec/html/proofer/fixtures/links/folder/index.html
199
+ - spec/html/proofer/fixtures/links/folder/relativeImage.html
200
+ - spec/html/proofer/fixtures/links/gpl.png
201
+ - spec/html/proofer/fixtures/links/head_link_href.html
202
+ - spec/html/proofer/fixtures/links/head_link_href_absent.html
203
+ - spec/html/proofer/fixtures/links/head_link_href_empty.html
204
+ - spec/html/proofer/fixtures/links/ignorableLinks.html
205
+ - spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html
206
+ - spec/html/proofer/fixtures/links/index.html
207
+ - spec/html/proofer/fixtures/links/javascript_link.html
208
+ - spec/html/proofer/fixtures/links/linkToFolder.html
209
+ - spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html
210
+ - spec/html/proofer/fixtures/links/linkWithHttps.html
211
+ - spec/html/proofer/fixtures/links/linkWithRedirect.html
212
+ - spec/html/proofer/fixtures/links/link_directory_without_slash.html
213
+ - spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html
214
+ - spec/html/proofer/fixtures/links/link_missing_protocol_valid.html
215
+ - spec/html/proofer/fixtures/links/links_in_pre.html
216
+ - spec/html/proofer/fixtures/links/mailto_link.html
217
+ - spec/html/proofer/fixtures/links/missingLinkHref.html
218
+ - spec/html/proofer/fixtures/links/multipleProblems.html
219
+ - spec/html/proofer/fixtures/links/notarealhash.html
220
+ - spec/html/proofer/fixtures/links/relativeLinks.html
221
+ - spec/html/proofer/fixtures/links/rootLink.html
222
+ - spec/html/proofer/fixtures/links/tel_link.html
223
+ - spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png
224
+ - spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg
225
+ - spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg
226
+ - spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg
227
+ - spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html
228
+ - spec/html/proofer/fixtures/resources/gpl.png
229
+ - spec/html/proofer/fixtures/scripts/script.js
230
+ - spec/html/proofer/fixtures/scripts/script_broken_external.html
231
+ - spec/html/proofer/fixtures/scripts/script_content.html
232
+ - spec/html/proofer/fixtures/scripts/script_content_absent.html
233
+ - spec/html/proofer/fixtures/scripts/script_in_pre.html
234
+ - spec/html/proofer/fixtures/scripts/script_missing_internal.html
235
+ - spec/html/proofer/fixtures/scripts/script_valid_internal.html
236
+ - spec/html/proofer/images_spec.rb
237
+ - spec/html/proofer/links_spec.rb
238
+ - spec/html/proofer/scripts_spec.rb
239
+ - spec/html/proofer_spec.rb
240
+ - spec/spec_helper.rb
156
241
  homepage: https://github.com/gjtorikian/html-proofer
157
242
  licenses:
158
243
  - MIT
@@ -179,4 +264,82 @@ specification_version: 4
179
264
  summary: A set of tests to validate your HTML output. These tests check if your image
180
265
  references are legitimate, if they have alt tags, if your internal links are working,
181
266
  and so on. It's intended to be an all-in-one checker for your documentation output.
182
- test_files: []
267
+ test_files:
268
+ - spec/html/proofer/favicon_spec.rb
269
+ - spec/html/proofer/fixtures/favicon/favicon_absent.html
270
+ - spec/html/proofer/fixtures/favicon/favicon_absent_apple.html
271
+ - spec/html/proofer/fixtures/favicon/favicon_broken.html
272
+ - spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html
273
+ - spec/html/proofer/fixtures/favicon/favicon_present.html
274
+ - spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html
275
+ - spec/html/proofer/fixtures/images/existingImageExternal.html
276
+ - spec/html/proofer/fixtures/images/gpl.png
277
+ - spec/html/proofer/fixtures/images/ignorableAltViaOptions.html
278
+ - spec/html/proofer/fixtures/images/ignorableImages.html
279
+ - spec/html/proofer/fixtures/images/ignoreAltButNotLink.html
280
+ - spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html
281
+ - spec/html/proofer/fixtures/images/image_missing_protocol_valid.html
282
+ - spec/html/proofer/fixtures/images/missingImageAlt.html
283
+ - spec/html/proofer/fixtures/images/missingImageAltText.html
284
+ - spec/html/proofer/fixtures/images/missingImageExternal.html
285
+ - spec/html/proofer/fixtures/images/missingImageInternal.html
286
+ - spec/html/proofer/fixtures/images/missingImageSrc.html
287
+ - spec/html/proofer/fixtures/images/relativeToSelf.html
288
+ - spec/html/proofer/fixtures/images/rootRelativeImages.html
289
+ - spec/html/proofer/fixtures/images/terribleImageName.html
290
+ - spec/html/proofer/fixtures/images/workingDataURIImage.html
291
+ - spec/html/proofer/fixtures/links/anchors_in_pre.html
292
+ - spec/html/proofer/fixtures/links/blank_mailto_link.html
293
+ - spec/html/proofer/fixtures/links/blank_tel_link.html
294
+ - spec/html/proofer/fixtures/links/brokenHashExternal.html
295
+ - spec/html/proofer/fixtures/links/brokenHashInternal.html
296
+ - spec/html/proofer/fixtures/links/brokenInternalLink.html
297
+ - spec/html/proofer/fixtures/links/brokenLinkExternal.html
298
+ - spec/html/proofer/fixtures/links/brokenLinkInternal.html
299
+ - spec/html/proofer/fixtures/links/brokenLinkWithNumber.html
300
+ - spec/html/proofer/fixtures/links/checkSSLLinks.html
301
+ - spec/html/proofer/fixtures/links/folder/anchorLink.html
302
+ - spec/html/proofer/fixtures/links/folder/assets/barrel.png
303
+ - spec/html/proofer/fixtures/links/folder/index.html
304
+ - spec/html/proofer/fixtures/links/folder/relativeImage.html
305
+ - spec/html/proofer/fixtures/links/gpl.png
306
+ - spec/html/proofer/fixtures/links/head_link_href.html
307
+ - spec/html/proofer/fixtures/links/head_link_href_absent.html
308
+ - spec/html/proofer/fixtures/links/head_link_href_empty.html
309
+ - spec/html/proofer/fixtures/links/ignorableLinks.html
310
+ - spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html
311
+ - spec/html/proofer/fixtures/links/index.html
312
+ - spec/html/proofer/fixtures/links/javascript_link.html
313
+ - spec/html/proofer/fixtures/links/linkToFolder.html
314
+ - spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html
315
+ - spec/html/proofer/fixtures/links/linkWithHttps.html
316
+ - spec/html/proofer/fixtures/links/linkWithRedirect.html
317
+ - spec/html/proofer/fixtures/links/link_directory_without_slash.html
318
+ - spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html
319
+ - spec/html/proofer/fixtures/links/link_missing_protocol_valid.html
320
+ - spec/html/proofer/fixtures/links/links_in_pre.html
321
+ - spec/html/proofer/fixtures/links/mailto_link.html
322
+ - spec/html/proofer/fixtures/links/missingLinkHref.html
323
+ - spec/html/proofer/fixtures/links/multipleProblems.html
324
+ - spec/html/proofer/fixtures/links/notarealhash.html
325
+ - spec/html/proofer/fixtures/links/relativeLinks.html
326
+ - spec/html/proofer/fixtures/links/rootLink.html
327
+ - spec/html/proofer/fixtures/links/tel_link.html
328
+ - spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png
329
+ - spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg
330
+ - spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg
331
+ - spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg
332
+ - spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html
333
+ - spec/html/proofer/fixtures/resources/gpl.png
334
+ - spec/html/proofer/fixtures/scripts/script.js
335
+ - spec/html/proofer/fixtures/scripts/script_broken_external.html
336
+ - spec/html/proofer/fixtures/scripts/script_content.html
337
+ - spec/html/proofer/fixtures/scripts/script_content_absent.html
338
+ - spec/html/proofer/fixtures/scripts/script_in_pre.html
339
+ - spec/html/proofer/fixtures/scripts/script_missing_internal.html
340
+ - spec/html/proofer/fixtures/scripts/script_valid_internal.html
341
+ - spec/html/proofer/images_spec.rb
342
+ - spec/html/proofer/links_spec.rb
343
+ - spec/html/proofer/scripts_spec.rb
344
+ - spec/html/proofer_spec.rb
345
+ - spec/spec_helper.rb