html_validation 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/html_validation/have_valid_html.rb +3 -1
- data/lib/html_validation/version.rb +1 -1
- metadata +6 -23
- data/.document +0 -5
- data/.gitignore +0 -4
- data/Gemfile +0 -24
- data/Gemfile.lock +0 -31
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -139
- data/Rakefile +0 -2
- data/html_validation.gemspec +0 -18
- data/spec/helpers/html_validation_helpers.rb +0 -23
- data/spec/html_validation_matcher_spec.rb +0 -40
- data/spec/html_validation_spec.rb +0 -161
- data/spec/spec_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc55d19a46fb63a6d3dac37c6066979775ae0f69
|
4
|
+
data.tar.gz: 4c5c1aab4f9c96f1e8c90e2b6c57418ee996e819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b1a6f0d4427394d7707f4e3419fc57418c1633b1ad7dd1d4235a4c22a81f143c44412dff8a0ede6cf4e5ec1641461e48c145e718360e5ad9e14f9e94feb1a28
|
7
|
+
data.tar.gz: d09f43024edc2358e5c45c9e02ced5992c52ed4c4d34ab1769903c2d334693a587a9d9eefff9724a2673f48969da8e2be5d1dba9923ffdb0c4d369f75ae1475f
|
@@ -27,10 +27,12 @@ module PageValidations
|
|
27
27
|
def failure_message_for_should
|
28
28
|
"#{@v.resource} Invalid html (fix or run 'html_validation review' to add exceptions)\n#{@v.resource} exceptions:\n #{@v.exceptions}\n\n #{@v.html if @@html_in_failures}"
|
29
29
|
end
|
30
|
+
alias :failure_message :failure_message_for_should
|
30
31
|
|
31
32
|
def failure_message_for_should_not
|
32
33
|
"#{@v.resource} Expected valid? to fail but didn't. Did you accidentally accept these validation errors? \n#{@v.resource} exceptions:\n #{@v.exceptions}\n\n #{@v.html if @@html_in_failures}"
|
33
34
|
end
|
35
|
+
alias :failure_message_when_negated :failure_message_for_should_not
|
34
36
|
|
35
37
|
end
|
36
38
|
|
@@ -38,4 +40,4 @@ module PageValidations
|
|
38
40
|
HaveValidHTML.new
|
39
41
|
end
|
40
42
|
|
41
|
-
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Beland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: HTML Validation lets you validate html locally. Lets you build html validation
|
14
14
|
into your test suite, but break the rules if you must.
|
@@ -19,25 +19,12 @@ executables:
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- .document
|
23
|
-
- .gitignore
|
24
|
-
- .rspec
|
25
|
-
- Gemfile
|
26
|
-
- Gemfile.lock
|
27
|
-
- LICENSE.txt
|
28
|
-
- README.rdoc
|
29
|
-
- Rakefile
|
30
22
|
- bin/html_validation
|
31
|
-
- html_validation.gemspec
|
32
23
|
- lib/html_validation.rb
|
33
24
|
- lib/html_validation/have_valid_html.rb
|
34
25
|
- lib/html_validation/html_validation_result.rb
|
35
26
|
- lib/html_validation/page_validations.rb
|
36
27
|
- lib/html_validation/version.rb
|
37
|
-
- spec/helpers/html_validation_helpers.rb
|
38
|
-
- spec/html_validation_matcher_spec.rb
|
39
|
-
- spec/html_validation_spec.rb
|
40
|
-
- spec/spec_helper.rb
|
41
28
|
homepage: https://github.com/ericbeland/html_validation
|
42
29
|
licenses:
|
43
30
|
- MIT
|
@@ -48,22 +35,18 @@ require_paths:
|
|
48
35
|
- lib
|
49
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
37
|
requirements:
|
51
|
-
- -
|
38
|
+
- - ">="
|
52
39
|
- !ruby/object:Gem::Version
|
53
40
|
version: '0'
|
54
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
42
|
requirements:
|
56
|
-
- -
|
43
|
+
- - ">="
|
57
44
|
- !ruby/object:Gem::Version
|
58
45
|
version: '0'
|
59
46
|
requirements: []
|
60
47
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.2.
|
48
|
+
rubygems_version: 2.2.2
|
62
49
|
signing_key:
|
63
50
|
specification_version: 4
|
64
51
|
summary: Local HTML validation for tests and RSpec.
|
65
|
-
test_files:
|
66
|
-
- spec/helpers/html_validation_helpers.rb
|
67
|
-
- spec/html_validation_matcher_spec.rb
|
68
|
-
- spec/html_validation_spec.rb
|
69
|
-
- spec/spec_helper.rb
|
52
|
+
test_files: []
|
data/.document
DELETED
data/.gitignore
DELETED
data/Gemfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
|
-
group :development do
|
8
|
-
gem "rspec"
|
9
|
-
gem "bundler"
|
10
|
-
end
|
11
|
-
|
12
|
-
gem 'rdoc'
|
13
|
-
gem 'thor'
|
14
|
-
|
15
|
-
# Unix Rubies (OSX, Linux)
|
16
|
-
platform :ruby do
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
# Windows Rubies (RubyInstaller)
|
21
|
-
platforms :mswin, :mingw do
|
22
|
-
|
23
|
-
end
|
24
|
-
|
data/Gemfile.lock
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
html_validation (1.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.1.3)
|
10
|
-
json (1.7.7)
|
11
|
-
rdoc (4.0.0)
|
12
|
-
json (~> 1.4)
|
13
|
-
rspec (2.11.0)
|
14
|
-
rspec-core (~> 2.11.0)
|
15
|
-
rspec-expectations (~> 2.11.0)
|
16
|
-
rspec-mocks (~> 2.11.0)
|
17
|
-
rspec-core (2.11.1)
|
18
|
-
rspec-expectations (2.11.2)
|
19
|
-
diff-lcs (~> 1.1.3)
|
20
|
-
rspec-mocks (2.11.1)
|
21
|
-
thor (0.17.0)
|
22
|
-
|
23
|
-
PLATFORMS
|
24
|
-
ruby
|
25
|
-
|
26
|
-
DEPENDENCIES
|
27
|
-
bundler
|
28
|
-
html_validation!
|
29
|
-
rdoc
|
30
|
-
rspec
|
31
|
-
thor
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 - 2013 Eric Beland
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
= HTML Validation
|
2
|
-
|
3
|
-
html_validation helps you validate, track, and fix or accept HTML validation
|
4
|
-
issues without depending on an external web service.
|
5
|
-
The idea is to take an HTML markup string associated
|
6
|
-
with a particular resource (file or URL) and validate it locally.
|
7
|
-
No web connection or dependency on a 3rd party web service is involved--just an
|
8
|
-
install of HTML Tidy, which is supported by the W3C. An RSpec matcher is included.
|
9
|
-
|
10
|
-
HTML Validation is intended to be used in acceptance tests, test suites or rake
|
11
|
-
tasks to alert you to changes in your html's validity so you can fix them, or
|
12
|
-
barring that, review and accept any errors and warnings.
|
13
|
-
|
14
|
-
== HTML 5
|
15
|
-
|
16
|
-
The current (as of May 2013) default version of Tidy doesn't support HTML 5.
|
17
|
-
To get HTML 5 support, install this fork of tidy: https://github.com/w3c/tidy-html5
|
18
|
-
|
19
|
-
Download the repo as a zip file and extract somewhere, then follow the instructions
|
20
|
-
given on the page (using sudo for make commands if on Linux). Add it to the PATH.
|
21
|
-
Note that OS X and Debian like to install the old version of tidy in /usr/bin so
|
22
|
-
if you don't remove it or place the newer one earlier on the PATH, sadness may ensue.
|
23
|
-
|
24
|
-
On linux/OS X machines, confirm the right installation path using: which tidy
|
25
|
-
|
26
|
-
== RSpec Setup / Usage:
|
27
|
-
Add to spec/spec_helper.rb:
|
28
|
-
|
29
|
-
require 'html_validation'
|
30
|
-
include PageValidations
|
31
|
-
|
32
|
-
Now, within your Integration Tests, you can do this:
|
33
|
-
|
34
|
-
page.should have_valid_html
|
35
|
-
|
36
|
-
or with the new syntax:
|
37
|
-
|
38
|
-
expect(page).to have_valid_html
|
39
|
-
|
40
|
-
It can be convenient to see the html printed in the RSpec failure messages.
|
41
|
-
To set this feature (globally for all):
|
42
|
-
|
43
|
-
HaveValidHTML.show_html_in_failures = true
|
44
|
-
|
45
|
-
|
46
|
-
All Tidy flags, including using a config file can be handled.
|
47
|
-
|
48
|
-
A shortcut to disable Tidy Warning messages (they are on by default)
|
49
|
-
has been created for your convenience. However, some things that might be
|
50
|
-
called "errors" show up as warnings, so the recommended approach is
|
51
|
-
run, then accept the errors / warnings that are noted. At your peril, the shortcut
|
52
|
-
is:
|
53
|
-
|
54
|
-
HTMLValidation.show_warnings = false
|
55
|
-
|
56
|
-
If you want to ignore specific errors, you can do the following :
|
57
|
-
|
58
|
-
HTMLValidation.ignored_attribute_errors = ['tabindex']
|
59
|
-
HTMLValidation.ignored_tag_errors = ['inline']
|
60
|
-
HTMLValidation.ignored_errors = ['missing li']
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
== Non-RSpec Usage:
|
65
|
-
|
66
|
-
require 'html_validation'
|
67
|
-
|
68
|
-
h = PageValidations::HTMLValidation.new
|
69
|
-
v = h.validation("<html>foo</html>", 'http://somesite.com/index.html')
|
70
|
-
|
71
|
-
# Note: The second argument (resource) just serves as an identifier used to
|
72
|
-
# name the results files, and no data is actually retrieved for you from on the URL!
|
73
|
-
|
74
|
-
v.valid?
|
75
|
-
-> false
|
76
|
-
|
77
|
-
v.exceptions
|
78
|
-
-> line 1 column 1 - Warning: missing <!DOCTYPE> declaration
|
79
|
-
-> line 1 column 9 - Warning: plain text isn't allowed in <head> elements
|
80
|
-
-> line 1 column 9 - Warning: inserting missing 'title' element
|
81
|
-
|
82
|
-
v.accept!
|
83
|
-
|
84
|
-
v.valid?
|
85
|
-
-> true
|
86
|
-
|
87
|
-
After the exceptions string has been accepted, the exceptions
|
88
|
-
are still available in v.exceptions even though valid? will return true.
|
89
|
-
This is so you can print them out, nag yourself, etc.
|
90
|
-
|
91
|
-
The exception string is treated and matched as a whole. The current
|
92
|
-
implementation does not allow partial acceptance of individual
|
93
|
-
results in a result string. However, line numbers are ignored, so there is
|
94
|
-
some flexibility in terms of being able to make changes without re-reviewing
|
95
|
-
what passes. Of course, if your HTML is totally clean, no worries.
|
96
|
-
|
97
|
-
== Accepting Errors / Warnings
|
98
|
-
|
99
|
-
The HTML Validation gem stores failure data per-resource. The results are stored
|
100
|
-
in the data_folder. Typically this is the default folder: .validation in the project root.
|
101
|
-
After a validation fails, run the thor task to accept or reject validation exceptions.
|
102
|
-
|
103
|
-
From your project's root folder, run: html_validation review
|
104
|
-
|
105
|
-
The result string is checked as a whole, so changes require re-review.
|
106
|
-
|
107
|
-
Note, if you configure an alternate data_folder, you may pass it as an option
|
108
|
-
to the Thor task.
|
109
|
-
|
110
|
-
|
111
|
-
== NOTES
|
112
|
-
|
113
|
-
This is untested on Windows as I don't have access to a Windows machine at the moment.
|
114
|
-
It is written so it could (probably) work on Windows. Pull requests in this area would
|
115
|
-
be welcomed.
|
116
|
-
|
117
|
-
== Requirements
|
118
|
-
|
119
|
-
HTML Tidy needs to be on the PATH.
|
120
|
-
|
121
|
-
Make sure the right Tidy is being picked up with: which tidy
|
122
|
-
|
123
|
-
|
124
|
-
== Contributing to html_validation
|
125
|
-
|
126
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
127
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
128
|
-
* Fork the project
|
129
|
-
* Start a feature/bugfix branch
|
130
|
-
* Commit and push until you are happy with your contribution
|
131
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
132
|
-
|
133
|
-
|
134
|
-
=== Running the tests
|
135
|
-
|
136
|
-
After tidy has been installed, in the gem folder, run: rspec spec
|
137
|
-
|
138
|
-
Copyright (c) 2012 Eric Beland. See LICENSE.txt for further details.
|
139
|
-
|
data/Rakefile
DELETED
data/html_validation.gemspec
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/html_validation/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Eric Beland"]
|
6
|
-
gem.email = ["ebeland@gmail.com"]
|
7
|
-
gem.description = %q{HTML Validation lets you validate html locally. Lets you build html validation into your test suite, but break the rules if you must.}
|
8
|
-
gem.summary = %q{Local HTML validation for tests and RSpec. }
|
9
|
-
gem.homepage = "https://github.com/ericbeland/html_validation"
|
10
|
-
|
11
|
-
gem.files = `git ls-files`.split($\)
|
12
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
-
gem.name = "html_validation"
|
14
|
-
gem.require_paths = ["lib"]
|
15
|
-
gem.executables = ['html_validation']
|
16
|
-
gem.version = PageValidations::HTML_VALIDATOR_VERSION
|
17
|
-
gem.license = 'MIT'
|
18
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module HTMLValidationHelpers
|
2
|
-
|
3
|
-
def bad_html
|
4
|
-
'<html><title>the title<title></head><body><p>blah blah</body></html>'
|
5
|
-
end
|
6
|
-
|
7
|
-
def good_html
|
8
|
-
html_5_doctype + '<html><title>the title</title></head><body><p>a paragraph</p></body></html>'
|
9
|
-
end
|
10
|
-
|
11
|
-
def dtd
|
12
|
-
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
13
|
-
end
|
14
|
-
|
15
|
-
def html_5_doctype
|
16
|
-
'<!DOCTYPE html>'
|
17
|
-
end
|
18
|
-
|
19
|
-
def warning_html
|
20
|
-
html_5_doctype + '<html><title proprietary="1">h</title></head><body><p>a para</p></body></html>'
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
require 'html_validation/have_valid_html'
|
4
|
-
|
5
|
-
describe "HTMLValidationRSpecMatcher" do
|
6
|
-
include HTMLValidationHelpers
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@page = double("page")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should check page object with the matcher for valid HTML and pass valid HTML" do
|
13
|
-
@page.stub :html => good_html
|
14
|
-
@page.stub :body => good_html
|
15
|
-
@page.stub :current_url => 'http://www.fake.com/good_page'
|
16
|
-
@page.should have_valid_html
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should check page object with the matcher for valid HTML and fail bad HTML" do
|
20
|
-
@page.stub :html => bad_html
|
21
|
-
@page.stub :body => bad_html
|
22
|
-
@page.stub :current_url => 'http://www.fake.com/bad_page'
|
23
|
-
@page.should_not have_valid_html
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def tmp_path
|
30
|
-
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
|
31
|
-
is_windows ? 'c:\temp\validation' : '/tmp/validation'
|
32
|
-
end
|
33
|
-
|
34
|
-
# clean our temp dir without killing it
|
35
|
-
def clean_dir(dir)
|
36
|
-
Dir.chdir(dir)
|
37
|
-
Dir.glob('*').each {|f| FileUtils.rm f }
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,161 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
|
4
|
-
describe "HTMLValidation" do
|
5
|
-
include HTMLValidationHelpers
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
FileUtils.mkdir tmp_path if !File.exists?('/tmp/validation')
|
9
|
-
@h = HTMLValidation.new('/tmp/validation')
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should return false for invalid HTML" do
|
13
|
-
result = @h.validation(bad_html, "http://myothersite.com").valid?.should be_false
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should return true for valid HTML" do
|
17
|
-
result = @h.validation(good_html, "http://mysite.com").valid?.should be_true
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should have an exception string for invalid HTML" do
|
21
|
-
result = @h.validation(bad_html, "http://myfavoritesite.com")
|
22
|
-
(result.exceptions.empty?).should be_false
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should return true for valid? if exceptions are accepted" do
|
26
|
-
result = @h.validation(bad_html, "http://mynewsite.com")
|
27
|
-
result.accept!
|
28
|
-
result = @h.validation(bad_html, "http://mynewsite.com").valid?.should be_true
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should show no exceptions for a truly valid file" do
|
32
|
-
result = @h.validation(good_html, "http://mybestsite.com")
|
33
|
-
(result.exceptions == '').should be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should still show exceptions when returning valid for an accepted exception string" do
|
37
|
-
result = @h.validation(bad_html, "http://myworstsite.com")
|
38
|
-
result.accept!
|
39
|
-
result = @h.validation(bad_html, "http://myworstsite.com")
|
40
|
-
result.valid?.should be_true
|
41
|
-
result.exceptions.length.should_not be_zero
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should reset exceptions after each call to valid?" do
|
45
|
-
result = @h.validation(bad_html, "http://myuglysite.com")
|
46
|
-
result = @h.validation(good_html, "http://myuglysite.com")
|
47
|
-
result.exceptions.length.should be_zero
|
48
|
-
result.valid?.should be_true
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should reset accepted exceptions string after seeing valid HTML for a path" do
|
52
|
-
result = @h.validation(bad_html, "http://notmysite.com")
|
53
|
-
result.accept!
|
54
|
-
result = @h.validation(bad_html, "http://notmysite.com").valid?.should be_true
|
55
|
-
# now we see valid, so we should reset
|
56
|
-
result = @h.validation(good_html, "http://notmysite.com").valid?.should be_true
|
57
|
-
result = @h.validation(bad_html, "http://notmysite.com").valid?.should be_false
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should not pass a different non-accepted exception" do
|
61
|
-
result = @h.validation(bad_html, "http://mycoolsite.com")
|
62
|
-
result.accept!
|
63
|
-
result = @h.validation("<html></body></html>", "http://mycoolsite.com").valid?.should be_false
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should ignore proprietary tags when ignore_proprietary is passed" do
|
67
|
-
html_with_proprietary=good_html.gsub('<body>','<body><textarea wrap="true" spellcheck="true">hi</textarea>')
|
68
|
-
result = @h.validation(html_with_proprietary, "http://mycrosoft.com")
|
69
|
-
result.valid?.should be_false
|
70
|
-
@h = HTMLValidation.new('/tmp/validation', [], :ignore_proprietary => true)
|
71
|
-
result = @h.validation(html_with_proprietary, "http://mycrosoft.com")
|
72
|
-
result.valid?.should be_true
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should work without a data path being manually set" do
|
76
|
-
h = HTMLValidation.new()
|
77
|
-
result = h.validation(good_html, "http://mybestsite.com")
|
78
|
-
result.exceptions.should be_empty
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should not show (should ignore) warnings when they are turned off" do
|
82
|
-
HTMLValidation.show_warnings = false
|
83
|
-
h = HTMLValidation.new()
|
84
|
-
result = h.validation(warning_html, "http://mywarningsite.com")
|
85
|
-
result.exceptions.should be_empty
|
86
|
-
HTMLValidation.show_warnings = true
|
87
|
-
h = HTMLValidation.new()
|
88
|
-
result = h.validation(warning_html, "http://myotherwarningsite.com")
|
89
|
-
result.exceptions.should_not be_empty
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should ignore ignored_attribute_errors' do
|
93
|
-
HTMLValidation.ignored_attribute_errors = ['tabindex']
|
94
|
-
h = HTMLValidation.new()
|
95
|
-
result = h.validation(good_html.gsub('<body>','<body><span tabindex="-1">blabla</span>'), "http://mywarningsite.com")
|
96
|
-
result.valid?.should be_true
|
97
|
-
HTMLValidation.ignored_attribute_errors = []
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should ignored_tag_errors' do
|
101
|
-
HTMLValidation.ignored_tag_errors = ['inline']
|
102
|
-
h = HTMLValidation.new()
|
103
|
-
result = h.validation(good_html.gsub('<body>','<body><inline>rrr</inline>'), "http://mywarningsite.com")
|
104
|
-
result.valid?.should be_true
|
105
|
-
HTMLValidation.ignored_tag_errors = []
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'should ignored_errors' do
|
109
|
-
HTMLValidation.ignored_errors = ['inline']
|
110
|
-
h = HTMLValidation.new()
|
111
|
-
result = h.validation(good_html.gsub('<body>','<body><inline>rrr</inline>'), "http://mywarningsite.com")
|
112
|
-
result.valid?.should be_true
|
113
|
-
HTMLValidation.ignored_errors = []
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "when launching HTML Tidy" do
|
117
|
-
|
118
|
-
it "should let me pass different Tidy command line options" do
|
119
|
-
@h = HTMLValidation.new('/tmp/validation')
|
120
|
-
result = @h.validation("<html>foo", 'c:\mycoolapp\somesite.html')
|
121
|
-
result.exceptions.include?("Warning:").should be_true
|
122
|
-
@h = HTMLValidation.new('/tmp/validation', ["--show-warnings false"])
|
123
|
-
result = @h.validation("<html>foo", 'c:\mycoolapp\somesite.html')
|
124
|
-
result.exceptions.include?("Warning:").should be_false
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "when walking exception results" do
|
130
|
-
|
131
|
-
it "should yield loaded exception results" do
|
132
|
-
@h = HTMLValidation.new('/tmp/validation')
|
133
|
-
result = @h.validation("<html>foo", 'c:\evencooler.com\somesite.html')
|
134
|
-
had_exceptions = false
|
135
|
-
@h.each_exception do |e|
|
136
|
-
had_exceptions = true
|
137
|
-
e.is_a?(HTMLValidationResult).should be_true
|
138
|
-
(e.resource.length > 0).should be_true
|
139
|
-
(e.html.length > 0).should be_true
|
140
|
-
end
|
141
|
-
had_exceptions.should be_true
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
private
|
148
|
-
|
149
|
-
|
150
|
-
def tmp_path
|
151
|
-
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
|
152
|
-
is_windows ? 'c:\temp\validation' : '/tmp/validation'
|
153
|
-
end
|
154
|
-
|
155
|
-
# clean our temp dir without killing it
|
156
|
-
def clean_dir(dir)
|
157
|
-
Dir.chdir(dir)
|
158
|
-
Dir.glob('*').each {|f| FileUtils.rm f }
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
require 'rspec'
|
4
|
-
require 'html_validation'
|
5
|
-
|
6
|
-
# Requires supporting files with custom matchers and macros, etc,
|
7
|
-
# in ./support/ and its subdirectories.
|
8
|
-
Dir["#{File.dirname(__FILE__)}/helpers/**/*.rb"].each {|f| require f }
|
9
|
-
|
10
|
-
include PageValidations
|
11
|
-
include HTMLValidationHelpers
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
|
15
|
-
|
16
|
-
end
|