html-proofer 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -5
- data/bin/htmlproof +2 -0
- data/html-proofer.gemspec +1 -1
- data/lib/html/proofer.rb +10 -3
- data/lib/html/proofer/checkable.rb +6 -7
- data/lib/html/proofer/checks.rb +7 -3
- data/lib/html/proofer/checks/favicon.rb +22 -0
- data/lib/html/proofer/checks/images.rb +7 -5
- data/lib/html/proofer/checks/links.rb +12 -2
- data/lib/html/proofer/checks/scripts.rb +40 -0
- data/spec/html/proofer/favicon_spec.rb +46 -0
- data/spec/html/proofer/fixtures/favicon/favicon_absent.html +4 -0
- data/spec/html/proofer/fixtures/favicon/favicon_absent_apple.html +7 -0
- data/spec/html/proofer/fixtures/favicon/favicon_broken.html +7 -0
- data/spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html +7 -0
- data/spec/html/proofer/fixtures/favicon/favicon_present.html +7 -0
- data/spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html +7 -0
- data/spec/html/proofer/fixtures/{existingImageExternal.html → images/existingImageExternal.html} +0 -0
- data/spec/html/proofer/fixtures/{gpl.png → images/gpl.png} +0 -0
- data/spec/html/proofer/fixtures/{ignorableImages.html → images/ignorableImages.html} +0 -0
- data/spec/html/proofer/fixtures/{image_missing_protocol_invalid.html → images/image_missing_protocol_invalid.html} +0 -0
- data/spec/html/proofer/fixtures/{image_missing_protocol_valid.html → images/image_missing_protocol_valid.html} +0 -0
- data/spec/html/proofer/fixtures/{missingImageAlt.html → images/missingImageAlt.html} +0 -0
- data/spec/html/proofer/fixtures/{missingImageAltText.html → images/missingImageAltText.html} +0 -0
- data/spec/html/proofer/fixtures/{missingImageExternal.html → images/missingImageExternal.html} +0 -0
- data/spec/html/proofer/fixtures/{missingImageInternal.html → images/missingImageInternal.html} +0 -0
- data/spec/html/proofer/fixtures/{missingImageSrc.html → images/missingImageSrc.html} +0 -0
- data/spec/html/proofer/fixtures/images/relativeToSelf.html +2 -0
- data/spec/html/proofer/fixtures/{rootRelativeImages.html → images/rootRelativeImages.html} +0 -0
- data/spec/html/proofer/fixtures/{terribleImageName.html → images/terribleImageName.html} +0 -0
- data/spec/html/proofer/fixtures/{workingDataURIImage.html → images/workingDataURIImage.html} +0 -0
- data/spec/html/proofer/fixtures/{blank_mailto_link.html → links/blank_mailto_link.html} +0 -0
- data/spec/html/proofer/fixtures/{blank_tel_link.html → links/blank_tel_link.html} +0 -0
- data/spec/html/proofer/fixtures/{brokenHashExternal.html → links/brokenHashExternal.html} +2 -2
- data/spec/html/proofer/fixtures/{brokenHashInternal.html → links/brokenHashInternal.html} +0 -0
- data/spec/html/proofer/fixtures/{brokenInternalLink.html → links/brokenInternalLink.html} +0 -0
- data/spec/html/proofer/fixtures/{brokenLinkExternal.html → links/brokenLinkExternal.html} +0 -0
- data/spec/html/proofer/fixtures/{brokenLinkInternal.html → links/brokenLinkInternal.html} +0 -0
- data/spec/html/proofer/fixtures/{brokenLinkWithNumber.html → links/brokenLinkWithNumber.html} +0 -0
- data/spec/html/proofer/fixtures/{checkSSLLinks.html → links/checkSSLLinks.html} +0 -0
- data/spec/html/proofer/fixtures/{folder → links/folder}/anchorLink.html +0 -0
- data/spec/html/proofer/fixtures/{folder → links/folder}/assets/barrel.png +0 -0
- data/spec/html/proofer/fixtures/{folder → links/folder}/index.html +0 -0
- data/spec/html/proofer/fixtures/{folder → links/folder}/relativeImage.html +0 -0
- data/spec/html/proofer/fixtures/links/gpl.png +0 -0
- data/spec/html/proofer/fixtures/{head_link_href.html → links/head_link_href.html} +0 -0
- data/spec/html/proofer/fixtures/{head_link_href_absent.html → links/head_link_href_absent.html} +0 -0
- data/spec/html/proofer/fixtures/{head_link_href_empty.html → links/head_link_href_empty.html} +0 -0
- data/spec/html/proofer/fixtures/{ignorableLinks.html → links/ignorableLinks.html} +0 -0
- data/spec/html/proofer/fixtures/{ignorableLinksViaOptions.html → links/ignorableLinksViaOptions.html} +0 -0
- data/spec/html/proofer/fixtures/{index.html → links/index.html} +0 -0
- data/spec/html/proofer/fixtures/{linkToFolder.html → links/linkToFolder.html} +0 -0
- data/spec/html/proofer/fixtures/{linkTranslatedViaHrefSwap.html → links/linkTranslatedViaHrefSwap.html} +0 -0
- data/spec/html/proofer/fixtures/{linkWithHttps.html → links/linkWithHttps.html} +0 -0
- data/spec/html/proofer/fixtures/{linkWithRedirect.html → links/linkWithRedirect.html} +0 -0
- data/spec/html/proofer/fixtures/links/link_directory_without_slash.html +1 -0
- data/spec/html/proofer/fixtures/{link_missing_protocol_invalid.html → links/link_missing_protocol_invalid.html} +0 -0
- data/spec/html/proofer/fixtures/{link_missing_protocol_valid.html → links/link_missing_protocol_valid.html} +0 -0
- data/spec/html/proofer/fixtures/{mailto_link.html → links/mailto_link.html} +0 -0
- data/spec/html/proofer/fixtures/{missingLinkHref.html → links/missingLinkHref.html} +0 -0
- data/spec/html/proofer/fixtures/{multipleProblems.html → links/multipleProblems.html} +0 -0
- data/spec/html/proofer/fixtures/{notarealhash.html → links/notarealhash.html} +0 -0
- data/spec/html/proofer/fixtures/{relativeLinks.html → links/relativeLinks.html} +0 -2
- data/spec/html/proofer/fixtures/{rootLink.html → links/rootLink.html} +0 -0
- data/spec/html/proofer/fixtures/{tel_link.html → links/tel_link.html} +0 -0
- data/spec/html/proofer/fixtures/Screen Shot 2012-08-09 at 7.51.18 AM.png b/data/spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 → AM.png +0 -0
- data/spec/html/proofer/fixtures/resources/gpl.png +0 -0
- data/spec/html/proofer/fixtures/scripts/script.js +1 -0
- data/spec/html/proofer/fixtures/scripts/script_broken_external.html +9 -0
- data/spec/html/proofer/fixtures/scripts/script_content.html +9 -0
- data/spec/html/proofer/fixtures/scripts/script_content_absent.html +9 -0
- data/spec/html/proofer/fixtures/scripts/script_missing_internal.html +9 -0
- data/spec/html/proofer/fixtures/scripts/script_valid_internal.html +9 -0
- data/spec/html/proofer/images_spec.rb +20 -14
- data/spec/html/proofer/links_spec.rb +41 -27
- data/spec/html/proofer/scripts_spec.rb +35 -0
- data/spec/html/proofer_spec.rb +2 -2
- metadata +132 -94
File without changes
|
File without changes
|
File without changes
|
data/spec/html/proofer/fixtures/{brokenLinkWithNumber.html → links/brokenLinkWithNumber.html}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
File without changes
|
data/spec/html/proofer/fixtures/{head_link_href_absent.html → links/head_link_href_absent.html}
RENAMED
File without changes
|
data/spec/html/proofer/fixtures/{head_link_href_empty.html → links/head_link_href_empty.html}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<a href="folder">Folder</a>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
var x = 1;
|
@@ -1,56 +1,56 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "Images test" do
|
4
4
|
it "passes for existing external images" do
|
5
|
-
externalImageFilepath = "#{FIXTURES_DIR}/existingImageExternal.html"
|
5
|
+
externalImageFilepath = "#{FIXTURES_DIR}/images/existingImageExternal.html"
|
6
6
|
output = capture_stderr { HTML::Proofer.new(externalImageFilepath).run }
|
7
7
|
output.should == ""
|
8
8
|
end
|
9
9
|
|
10
10
|
it "fails for image without alt attribute" do
|
11
|
-
missingAltFilepath = "#{FIXTURES_DIR}/missingImageAlt.html"
|
11
|
+
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
|
12
12
|
output = capture_stderr { HTML::Proofer.new(missingAltFilepath).run }
|
13
13
|
output.should match /gpl.png does not have an alt attribute/
|
14
14
|
end
|
15
15
|
|
16
16
|
it "fails for image with an empty alt attribute" do
|
17
|
-
missingAltFilepath = "#{FIXTURES_DIR}/missingImageAltText.html"
|
17
|
+
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAltText.html"
|
18
18
|
output = capture_stderr { HTML::Proofer.new(missingAltFilepath).run }
|
19
19
|
output.should match /gpl.png does not have an alt attribute/
|
20
20
|
end
|
21
21
|
|
22
22
|
it "fails for missing external images" do
|
23
|
-
externalImageFilepath = "#{FIXTURES_DIR}/missingImageExternal.html"
|
23
|
+
externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
|
24
24
|
output = capture_stderr { HTML::Proofer.new(externalImageFilepath).run }
|
25
25
|
output.should match /External link http:\/\/www.whatthehell\/? failed: 0 Couldn't resolve host/
|
26
26
|
end
|
27
27
|
|
28
28
|
it "fails for missing internal images" do
|
29
|
-
internalImageFilepath = "#{FIXTURES_DIR}/missingImageInternal.html"
|
29
|
+
internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
|
30
30
|
output = capture_stderr { HTML::Proofer.new(internalImageFilepath).run }
|
31
31
|
output.should match /doesnotexist.png does not exist/
|
32
32
|
end
|
33
33
|
|
34
34
|
it "fails for image with no src" do
|
35
|
-
imageSrcFilepath = "#{FIXTURES_DIR}/missingImageSrc.html"
|
35
|
+
imageSrcFilepath = "#{FIXTURES_DIR}/images/missingImageSrc.html"
|
36
36
|
output = capture_stderr { HTML::Proofer.new(imageSrcFilepath).run }
|
37
37
|
output.should match /image has no src attribute/
|
38
38
|
end
|
39
39
|
|
40
40
|
it "fails for image with default mac filename" do
|
41
|
-
terribleImageName = "#{FIXTURES_DIR}/terribleImageName.html"
|
41
|
+
terribleImageName = "#{FIXTURES_DIR}/images/terribleImageName.html"
|
42
42
|
output = capture_stderr { HTML::Proofer.new(terribleImageName).run }
|
43
43
|
output.should match /image has a terrible filename/
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'ignores images marked as ignore data-proofer-ignore' do
|
47
|
-
ignorableImages = "#{FIXTURES_DIR}/ignorableImages.html"
|
47
|
+
ignorableImages = "#{FIXTURES_DIR}/images/ignorableImages.html"
|
48
48
|
output = capture_stderr { HTML::Proofer.new(ignorableImages).run }
|
49
49
|
output.should == ""
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'properly checks relative images' do
|
53
|
-
relativeImages = "#{FIXTURES_DIR}/rootRelativeImages.html"
|
53
|
+
relativeImages = "#{FIXTURES_DIR}/images/rootRelativeImages.html"
|
54
54
|
output = capture_stderr { HTML::Proofer.new(relativeImages).run }
|
55
55
|
output.should == ""
|
56
56
|
|
@@ -59,21 +59,27 @@ describe "Image tests" do
|
|
59
59
|
output.should == ""
|
60
60
|
end
|
61
61
|
|
62
|
-
it 'properly
|
63
|
-
dataURIImage = "#{FIXTURES_DIR}/workingDataURIImage.html"
|
62
|
+
it 'properly ignores data URI images' do
|
63
|
+
dataURIImage = "#{FIXTURES_DIR}/images/workingDataURIImage.html"
|
64
64
|
output = capture_stderr { HTML::Proofer.new(dataURIImage).run }
|
65
65
|
output.should == ""
|
66
66
|
end
|
67
67
|
|
68
68
|
it "works for valid images missing the protocol" do
|
69
|
-
missingProtocolLink = "#{FIXTURES_DIR}/image_missing_protocol_valid.html"
|
69
|
+
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
|
70
70
|
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
71
71
|
output.should == ""
|
72
72
|
end
|
73
73
|
|
74
74
|
it "fails for invalid images missing the protocol" do
|
75
|
-
missingProtocolLink = "#{FIXTURES_DIR}/image_missing_protocol_invalid.html"
|
75
|
+
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
|
76
76
|
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
77
77
|
output.should match /404 No error/
|
78
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
|
79
85
|
end
|
@@ -1,154 +1,168 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "Links
|
3
|
+
describe "Links test" do
|
4
4
|
|
5
5
|
it "fails for broken external hash (even if the file exists)" do
|
6
|
-
brokenHashExternalFilepath = "#{FIXTURES_DIR}/brokenHashExternal.html"
|
6
|
+
brokenHashExternalFilepath = "#{FIXTURES_DIR}/links/brokenHashExternal.html"
|
7
7
|
output = capture_stderr { HTML::Proofer.new(brokenHashExternalFilepath).run }
|
8
|
-
output.should match /linking to
|
8
|
+
output.should match /linking to ..\/images\/missingImageAlt.html#asdfasfdkafl, but asdfasfdkafl does not exist/
|
9
9
|
end
|
10
10
|
|
11
11
|
it "fails for broken internal hash" do
|
12
|
-
brokenHashInternalFilepath = "#{FIXTURES_DIR}/brokenHashInternal.html"
|
12
|
+
brokenHashInternalFilepath = "#{FIXTURES_DIR}/links/brokenHashInternal.html"
|
13
13
|
output = capture_stderr { HTML::Proofer.new(brokenHashInternalFilepath).run }
|
14
14
|
output.should match /linking to internal hash #noHash that does not exist/
|
15
15
|
end
|
16
16
|
|
17
17
|
it "fails for broken external links" do
|
18
|
-
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/brokenLinkExternal.html"
|
18
|
+
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkExternal.html"
|
19
19
|
output = capture_stderr { HTML::Proofer.new(brokenLinkExternalFilepath).run }
|
20
20
|
output.should match /External link http:\/\/www.asdo3IRJ395295jsingrkrg4.com\/? failed: 0 Couldn't resolve host name/
|
21
21
|
end
|
22
22
|
|
23
23
|
it "fails for broken internal links" do
|
24
|
-
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/brokenLinkInternal.html"
|
24
|
+
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
|
25
25
|
output = capture_stderr { HTML::Proofer.new(brokenLinkInternalFilepath).run }
|
26
26
|
output.should match /internally linking to .\/notreal.html, which does not exist/
|
27
27
|
end
|
28
28
|
|
29
29
|
it "fails for link with no href" do
|
30
|
-
missingLinkHrefFilepath = "#{FIXTURES_DIR}/missingLinkHref.html"
|
30
|
+
missingLinkHrefFilepath = "#{FIXTURES_DIR}/links/missingLinkHref.html"
|
31
31
|
output = capture_stderr { HTML::Proofer.new(missingLinkHrefFilepath).run }
|
32
32
|
output.should match /link has no href attribute/
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should follow redirects" do
|
36
|
-
linkWithRedirectFilepath = "#{FIXTURES_DIR}/linkWithRedirect.html"
|
36
|
+
linkWithRedirectFilepath = "#{FIXTURES_DIR}/links/linkWithRedirect.html"
|
37
37
|
output = capture_stderr { HTML::Proofer.new(linkWithRedirectFilepath).run }
|
38
38
|
output.should == ""
|
39
39
|
end
|
40
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
|
+
|
41
48
|
it "should understand https" do
|
42
|
-
linkWithHttpsFilepath = "#{FIXTURES_DIR}/linkWithHttps.html"
|
49
|
+
linkWithHttpsFilepath = "#{FIXTURES_DIR}/links/linkWithHttps.html"
|
43
50
|
output = capture_stderr { HTML::Proofer.new(linkWithHttpsFilepath).run }
|
44
51
|
output.should == ""
|
45
52
|
end
|
46
53
|
|
47
54
|
it "fails for broken hash links with status code numbers" do
|
48
|
-
brokenLinkWithNumberFilepath = "#{FIXTURES_DIR}/brokenLinkWithNumber.html"
|
55
|
+
brokenLinkWithNumberFilepath = "#{FIXTURES_DIR}/links/brokenLinkWithNumber.html"
|
49
56
|
output = capture_stderr { HTML::Proofer.new(brokenLinkWithNumberFilepath).run }
|
50
57
|
output.should match /linking to internal hash #25-method-not-allowed that does not exist/
|
51
58
|
end
|
52
59
|
|
53
60
|
it 'properly resolves implicit /index.html in link paths' do
|
54
|
-
linkToFolder = "#{FIXTURES_DIR}/linkToFolder.html"
|
61
|
+
linkToFolder = "#{FIXTURES_DIR}/links/linkToFolder.html"
|
55
62
|
output = capture_stderr { HTML::Proofer.new(linkToFolder).run }
|
56
63
|
output.should == ""
|
57
64
|
end
|
58
65
|
|
59
66
|
it 'properly checks links to root' do
|
60
|
-
rootLink = "#{FIXTURES_DIR}/rootLink.html"
|
67
|
+
rootLink = "#{FIXTURES_DIR}/links/rootLink.html"
|
61
68
|
output = capture_stderr { HTML::Proofer.new(rootLink).run }
|
62
69
|
output.should == ""
|
63
70
|
end
|
64
71
|
|
65
72
|
it 'properly checks relative links' do
|
66
|
-
relativeLinks = "#{FIXTURES_DIR}/relativeLinks.html"
|
73
|
+
relativeLinks = "#{FIXTURES_DIR}/links/relativeLinks.html"
|
67
74
|
output = capture_stderr { HTML::Proofer.new(relativeLinks).run }
|
68
75
|
output.should == ""
|
69
76
|
end
|
70
77
|
|
71
78
|
it 'properly checks ssl links' do
|
72
|
-
checkSSLLinks = "#{FIXTURES_DIR}/checkSSLLinks.html"
|
79
|
+
checkSSLLinks = "#{FIXTURES_DIR}/links/checkSSLLinks.html"
|
73
80
|
output = capture_stderr { HTML::Proofer.new(checkSSLLinks).run }
|
74
81
|
output.should == ""
|
75
82
|
end
|
76
83
|
|
77
84
|
it 'ignores links marked as ignore data-proofer-ignore' do
|
78
|
-
ignorableLinks = "#{FIXTURES_DIR}/ignorableLinks.html"
|
85
|
+
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinks.html"
|
79
86
|
output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
|
80
87
|
output.should == ""
|
81
88
|
end
|
82
89
|
|
83
90
|
it 'ignores links via href_ignore' do
|
84
|
-
ignorableLinks = "#{FIXTURES_DIR}/ignorableLinksViaOptions.html"
|
91
|
+
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinksViaOptions.html"
|
85
92
|
output = capture_stderr { HTML::Proofer.new(ignorableLinks, {:href_ignore => [/^http:\/\//, /sdadsad/, "../whaadadt.html"]}).run }
|
86
93
|
output.should == ""
|
87
94
|
end
|
88
95
|
|
89
96
|
it 'translates links via href_swap' do
|
90
|
-
translatedLink = "#{FIXTURES_DIR}/linkTranslatedViaHrefSwap.html"
|
97
|
+
translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedViaHrefSwap.html"
|
91
98
|
output = capture_stderr { HTML::Proofer.new(translatedLink, {:href_swap => { /\A\/articles\/([\w-]+)/ => "\\1.html" }}).run }
|
92
99
|
output.should == ""
|
93
100
|
end
|
94
101
|
|
95
102
|
it 'finds a mix of broken and unbroken links' do
|
96
|
-
multipleProblems = "#{FIXTURES_DIR}/multipleProblems.html"
|
103
|
+
multipleProblems = "#{FIXTURES_DIR}/links/multipleProblems.html"
|
97
104
|
output = capture_stderr { HTML::Proofer.new(multipleProblems).run }
|
98
105
|
output.should match /linking to internal hash #anadaasdadsadschor that does not exist/
|
99
106
|
end
|
100
107
|
|
101
108
|
it 'ignores valid mailto links' do
|
102
|
-
ignorableLinks = "#{FIXTURES_DIR}/mailto_link.html"
|
109
|
+
ignorableLinks = "#{FIXTURES_DIR}/links/mailto_link.html"
|
103
110
|
output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
|
104
111
|
output.should == ""
|
105
112
|
end
|
106
113
|
|
107
114
|
it "fails for blank mailto links" do
|
108
|
-
blankMailToLink = "#{FIXTURES_DIR}/blank_mailto_link.html"
|
115
|
+
blankMailToLink = "#{FIXTURES_DIR}/links/blank_mailto_link.html"
|
109
116
|
output = capture_stderr { HTML::Proofer.new(blankMailToLink).run }
|
110
117
|
output.should match /mailto: is an invalid URL/
|
111
118
|
end
|
112
119
|
|
113
120
|
it 'ignores valid tel links' do
|
114
|
-
ignorableLinks = "#{FIXTURES_DIR}/tel_link.html"
|
121
|
+
ignorableLinks = "#{FIXTURES_DIR}/links/tel_link.html"
|
115
122
|
output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
|
116
123
|
output.should == ""
|
117
124
|
end
|
118
125
|
|
119
126
|
it "fails for blank tel links" do
|
120
|
-
blankTelLink = "#{FIXTURES_DIR}/blank_tel_link.html"
|
127
|
+
blankTelLink = "#{FIXTURES_DIR}/links/blank_tel_link.html"
|
121
128
|
output = capture_stderr { HTML::Proofer.new(blankTelLink).run }
|
122
129
|
output.should match /tel: is an invalid URL/
|
123
130
|
end
|
124
131
|
|
125
132
|
it "works for valid links missing the protocol" do
|
126
|
-
missingProtocolLink = "#{FIXTURES_DIR}/link_missing_protocol_valid.html"
|
133
|
+
missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_valid.html"
|
127
134
|
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
128
135
|
output.should == ""
|
129
136
|
end
|
130
137
|
|
131
138
|
it "fails for invalid links missing the protocol" do
|
132
|
-
missingProtocolLink = "#{FIXTURES_DIR}/link_missing_protocol_invalid.html"
|
139
|
+
missingProtocolLink = "#{FIXTURES_DIR}/links/link_missing_protocol_invalid.html"
|
133
140
|
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
134
141
|
output.should match /Couldn't resolve host name/
|
135
142
|
end
|
136
143
|
|
137
144
|
it "works for valid href within link elements" do
|
138
|
-
head_link = "#{FIXTURES_DIR}/head_link_href.html"
|
145
|
+
head_link = "#{FIXTURES_DIR}/links/head_link_href.html"
|
139
146
|
output = capture_stderr { HTML::Proofer.new(head_link).run }
|
140
147
|
output.should == ""
|
141
148
|
end
|
142
149
|
|
143
150
|
it "fails for empty href within link elements" do
|
144
|
-
head_link = "#{FIXTURES_DIR}/head_link_href_empty.html"
|
151
|
+
head_link = "#{FIXTURES_DIR}/links/head_link_href_empty.html"
|
145
152
|
output = capture_stderr { HTML::Proofer.new(head_link).run }
|
146
153
|
output.should match /link has no href attribute/
|
147
154
|
end
|
148
155
|
|
149
156
|
it "fails for absent href within link elements" do
|
150
|
-
head_link = "#{FIXTURES_DIR}/head_link_href_absent.html"
|
157
|
+
head_link = "#{FIXTURES_DIR}/links/head_link_href_absent.html"
|
151
158
|
output = capture_stderr { HTML::Proofer.new(head_link).run }
|
152
159
|
output.should match /link has no href attribute/
|
153
160
|
end
|
161
|
+
|
162
|
+
it "fails for internal linking to a directory without trailing slash" do
|
163
|
+
options = { :followlocation => false }
|
164
|
+
internal = "#{FIXTURES_DIR}/links/link_directory_without_slash.html"
|
165
|
+
output = capture_stderr { HTML::Proofer.new(internal, options).run }
|
166
|
+
output.should match /without trailing slash/
|
167
|
+
end
|
154
168
|
end
|
@@ -0,0 +1,35 @@
|
|
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
|
+
end
|