html-proofer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/html/proofer/check.rb +2 -0
- data/lib/html/proofer/checks/images.rb +6 -0
- data/lib/html/proofer/version.rb +1 -1
- data/spec/html/proofer/fixtures/Screen Shot 2012-08-09 at 7.51.18 AM.png +0 -0
- data/spec/html/proofer/fixtures/terribleImageName.html +9 -0
- data/spec/html/proofer/images_spec.rb +8 -1
- data/spec/html/proofer/links_spec.rb +3 -3
- metadata +6 -2
data/README.md
CHANGED
@@ -56,6 +56,7 @@ The `HTML::Proofer` constructor takes an optional hash of additional options:
|
|
56
56
|
* `:ext`: the extension (including the `.`) of your HTML files (default: `.html`)
|
57
57
|
* `:href_swap`: a hash containing key-value pairs of `RegExp => String`. It transforms links that match `RegExp` into `String` via `gsub`.
|
58
58
|
* `:href_ignore`: an array of Strings containing `href`s that are safe to ignore (default: `mailto`)
|
59
|
+
* `:longTests`: a Boolean indicating if long-running tests should run (for example, tests checking external links)
|
59
60
|
|
60
61
|
## What's Tested?
|
61
62
|
|
data/lib/html/proofer/check.rb
CHANGED
@@ -19,6 +19,12 @@ class Images < ::HTML::Proofer::Checks::Check
|
|
19
19
|
|
20
20
|
# check alt tag
|
21
21
|
self.add_issue("#{@path}".blue + ": image #{src} does not have an alt attribute") unless img['alt'] and !img['alt'].empty?
|
22
|
+
|
23
|
+
screenShotRegExp = /Screen\ Shot\ \d+-\d+-\d+ at \d+.\d+.\d+/
|
24
|
+
|
25
|
+
if src =~ screenShotRegExp
|
26
|
+
self.add_issue("#{@path}".blue + ": image has a terrible filename (#{src})")
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
data/lib/html/proofer/version.rb
CHANGED
Binary file
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe "Image tests" do
|
4
4
|
it "passes for existing external images" do
|
5
5
|
externalImageFilepath = "#{FIXTURES_DIR}/existingImageExternal.html"
|
6
|
-
@imageCheck = Images.new(externalImageFilepath, HTML::Proofer.create_nokogiri(externalImageFilepath))
|
6
|
+
@imageCheck = Images.new(externalImageFilepath, HTML::Proofer.create_nokogiri(externalImageFilepath), {:longTests => true})
|
7
7
|
@imageCheck.run
|
8
8
|
@imageCheck.issues[0].should eq(nil)
|
9
9
|
end
|
@@ -49,4 +49,11 @@ describe "Image tests" do
|
|
49
49
|
@imageCheck.run
|
50
50
|
@imageCheck.issues[0].should eq("spec/html/proofer/fixtures/missingImageSrc.html".blue + ": image has no src attribute")
|
51
51
|
end
|
52
|
+
|
53
|
+
it "fails for image with default mac filename" do
|
54
|
+
terribleImageName = "#{FIXTURES_DIR}/terribleImageName.html"
|
55
|
+
@imageCheck = Images.new(terribleImageName, HTML::Proofer.create_nokogiri(terribleImageName))
|
56
|
+
@imageCheck.run
|
57
|
+
@imageCheck.issues[0].should eq("spec/html/proofer/fixtures/terribleImageName.html".blue + ": image has a terrible filename (./Screen Shot 2012-08-09 at 7.51.18 AM.png)")
|
58
|
+
end
|
52
59
|
end
|
@@ -18,7 +18,7 @@ describe "Links tests" do
|
|
18
18
|
|
19
19
|
it "fails for broken external links" do
|
20
20
|
brokenLinkExternalFilepath = "#{FIXTURES_DIR}/brokenLinkExternal.html"
|
21
|
-
@linkCheck = Links.new(brokenLinkExternalFilepath, HTML::Proofer.create_nokogiri(brokenLinkExternalFilepath))
|
21
|
+
@linkCheck = Links.new(brokenLinkExternalFilepath, HTML::Proofer.create_nokogiri(brokenLinkExternalFilepath), {:longTests => true})
|
22
22
|
@linkCheck.run
|
23
23
|
@linkCheck.issues[0].should eq("spec/html/proofer/fixtures/brokenLinkExternal.html".blue + ": externally linking to http://www.asdo3IRJ395295jsingrkrg4.com, which does not exist")
|
24
24
|
end
|
@@ -39,14 +39,14 @@ describe "Links tests" do
|
|
39
39
|
|
40
40
|
it "should follow redirects" do
|
41
41
|
linkWithRedirectFilepath = "#{FIXTURES_DIR}/linkWithRedirect.html"
|
42
|
-
@linkCheck = Links.new(linkWithRedirectFilepath, HTML::Proofer.create_nokogiri(linkWithRedirectFilepath))
|
42
|
+
@linkCheck = Links.new(linkWithRedirectFilepath, HTML::Proofer.create_nokogiri(linkWithRedirectFilepath), {:longTests => true})
|
43
43
|
@linkCheck.run
|
44
44
|
@linkCheck.issues[0].should eq(nil)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should understand https" do
|
48
48
|
linkWithHttpsFilepath = "#{FIXTURES_DIR}/linkWithHttps.html"
|
49
|
-
@linkCheck = Links.new(linkWithHttpsFilepath, HTML::Proofer.create_nokogiri(linkWithHttpsFilepath))
|
49
|
+
@linkCheck = Links.new(linkWithHttpsFilepath, HTML::Proofer.create_nokogiri(linkWithHttpsFilepath), {:longTests => true})
|
50
50
|
@linkCheck.run
|
51
51
|
@linkCheck.issues[0].should eq(nil)
|
52
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/html/proofer/checks/images.rb
|
97
97
|
- lib/html/proofer/checks/links.rb
|
98
98
|
- lib/html/proofer/version.rb
|
99
|
+
- spec/html/proofer/fixtures/Screen Shot 2012-08-09 at 7.51.18 AM.png
|
99
100
|
- spec/html/proofer/fixtures/brokenHashExternal.html
|
100
101
|
- spec/html/proofer/fixtures/brokenHashInternal.html
|
101
102
|
- spec/html/proofer/fixtures/brokenLinkExternal.html
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- spec/html/proofer/fixtures/missingImageInternal.html
|
113
114
|
- spec/html/proofer/fixtures/missingImageSrc.html
|
114
115
|
- spec/html/proofer/fixtures/missingLinkHref.html
|
116
|
+
- spec/html/proofer/fixtures/terribleImageName.html
|
115
117
|
- spec/html/proofer/images_spec.rb
|
116
118
|
- spec/html/proofer/links_spec.rb
|
117
119
|
- spec/html/proofer/version_spec.rb
|
@@ -143,6 +145,7 @@ summary: A set of tests to validate your HTML output. These tests check if your
|
|
143
145
|
references are legitimate, if they have alt tags, if your internal links are working,
|
144
146
|
and so on. It's intended to be an all-in-one checker for your documentation output.
|
145
147
|
test_files:
|
148
|
+
- spec/html/proofer/fixtures/Screen Shot 2012-08-09 at 7.51.18 AM.png
|
146
149
|
- spec/html/proofer/fixtures/brokenHashExternal.html
|
147
150
|
- spec/html/proofer/fixtures/brokenHashInternal.html
|
148
151
|
- spec/html/proofer/fixtures/brokenLinkExternal.html
|
@@ -159,6 +162,7 @@ test_files:
|
|
159
162
|
- spec/html/proofer/fixtures/missingImageInternal.html
|
160
163
|
- spec/html/proofer/fixtures/missingImageSrc.html
|
161
164
|
- spec/html/proofer/fixtures/missingLinkHref.html
|
165
|
+
- spec/html/proofer/fixtures/terribleImageName.html
|
162
166
|
- spec/html/proofer/images_spec.rb
|
163
167
|
- spec/html/proofer/links_spec.rb
|
164
168
|
- spec/html/proofer/version_spec.rb
|