validate-website 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/lib/validate_website.rb +1 -0
- data/lib/validate_website/core.rb +33 -157
- data/lib/validate_website/crawl.rb +78 -0
- data/lib/validate_website/option_parser.rb +64 -59
- data/lib/validate_website/runner.rb +3 -3
- data/lib/validate_website/static.rb +102 -0
- data/lib/validate_website/validator.rb +44 -33
- data/lib/validate_website/version.rb +3 -0
- data/spec/core_spec.rb +3 -118
- data/spec/crawler_spec.rb +91 -0
- data/spec/data/w3.org-xhtml1-strict-errors.html +544 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/static_spec.rb +38 -0
- data/spec/validator_spec.rb +40 -23
- data/spec/webmock_helper.rb +4 -3
- metadata +30 -8
data/spec/spec_helper.rb
CHANGED
data/spec/static_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe ValidateWebsite::Static do
|
4
|
+
before do
|
5
|
+
@validate_website = ValidateWebsite::Static.new(color: false)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'no space in directory name' do
|
9
|
+
pattern = File.join(File.dirname(__FILE__), 'example/**/*.html')
|
10
|
+
@validate_website.crawl(pattern: pattern,
|
11
|
+
site: 'http://dev.af83.com/',
|
12
|
+
markup: false,
|
13
|
+
not_found: false)
|
14
|
+
@validate_website.not_founds_count.must_equal 0
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'not found' do
|
18
|
+
pattern = File.join(File.dirname(__FILE__), '**/*.html')
|
19
|
+
Dir.chdir('spec/data') do
|
20
|
+
@validate_website.crawl(pattern: pattern,
|
21
|
+
site: 'https://linuxfr.org/',
|
22
|
+
markup: false,
|
23
|
+
not_found: true)
|
24
|
+
@validate_website.not_founds_count.must_equal 503
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'ignore' do
|
29
|
+
pattern = File.join(File.dirname(__FILE__), 'data',
|
30
|
+
'w3.org-xhtml1-strict-errors.html')
|
31
|
+
Dir.chdir('spec/data') do
|
32
|
+
@validate_website.crawl(pattern: pattern,
|
33
|
+
site: 'http://w3.org/',
|
34
|
+
ignore: /height|width|Length/)
|
35
|
+
@validate_website.errors_count.must_equal 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/validator_spec.rb
CHANGED
@@ -2,13 +2,30 @@
|
|
2
2
|
require File.expand_path('../spec_helper', __FILE__)
|
3
3
|
|
4
4
|
describe ValidateWebsite::Validator do
|
5
|
+
let(:subject) { ValidateWebsite::Validator }
|
6
|
+
|
5
7
|
before do
|
6
8
|
WebMock.reset!
|
7
9
|
@http = Spidr::Agent.new
|
8
10
|
end
|
9
11
|
|
10
|
-
describe(
|
11
|
-
it
|
12
|
+
describe('xhtml1') do
|
13
|
+
it 'can ignore' do
|
14
|
+
name = 'w3.org-xhtml1-strict-errors'
|
15
|
+
file = File.join('spec', 'data', "#{name}.html")
|
16
|
+
page = FakePage.new(name,
|
17
|
+
body: open(file).read,
|
18
|
+
content_type: 'text/html')
|
19
|
+
@xhtml1_page = @http.get_page(page.url)
|
20
|
+
ignore = /width|height|Length/
|
21
|
+
validator = subject.new(@xhtml1_page.doc,
|
22
|
+
@xhtml1_page.body,
|
23
|
+
ignore)
|
24
|
+
validator.valid?.must_equal true
|
25
|
+
validator.errors.size.must_equal 0
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'xhtml1-strict should be valid' do
|
12
29
|
name = 'xhtml1-strict'
|
13
30
|
dtd_uri = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
|
14
31
|
file = File.join('spec', 'data', "#{name}.html")
|
@@ -16,8 +33,8 @@ describe ValidateWebsite::Validator do
|
|
16
33
|
body: open(file).read,
|
17
34
|
content_type: 'text/html')
|
18
35
|
@xhtml1_page = @http.get_page(page.url)
|
19
|
-
validator =
|
20
|
-
|
36
|
+
validator = subject.new(@xhtml1_page.doc,
|
37
|
+
@xhtml1_page.body)
|
21
38
|
validator.dtd.system_id.must_equal dtd_uri
|
22
39
|
validator.namespace.must_equal name
|
23
40
|
validator.valid?.must_equal true
|
@@ -28,36 +45,36 @@ describe ValidateWebsite::Validator do
|
|
28
45
|
describe('when valid') do
|
29
46
|
before do
|
30
47
|
validator_res = File.join('spec', 'data', 'validator.nu-success.html')
|
31
|
-
stub_request(:any,
|
48
|
+
stub_request(:any, subject.html5_validator_service_url)
|
32
49
|
.to_return(body: open(validator_res).read)
|
33
50
|
end
|
34
|
-
it
|
51
|
+
it 'html5 should be valid' do
|
35
52
|
name = 'html5'
|
36
53
|
file = File.join('spec', 'data', "#{name}.html")
|
37
54
|
page = FakePage.new(name,
|
38
55
|
body: open(file).read,
|
39
56
|
content_type: 'text/html')
|
40
57
|
@html5_page = @http.get_page(page.url)
|
41
|
-
validator =
|
42
|
-
|
58
|
+
validator = subject.new(@html5_page.doc,
|
59
|
+
@html5_page.body)
|
43
60
|
validator.valid?.must_equal true
|
44
61
|
end
|
45
|
-
it
|
62
|
+
it 'with DLFP' do
|
46
63
|
name = 'html5'
|
47
64
|
file = File.join('spec', 'data', "#{name}-linuxfr.html")
|
48
65
|
page = FakePage.new(name,
|
49
66
|
body: open(file).read,
|
50
67
|
content_type: 'text/html')
|
51
68
|
@html5_page = @http.get_page(page.url)
|
52
|
-
validator =
|
53
|
-
|
69
|
+
validator = subject.new(@html5_page.doc,
|
70
|
+
@html5_page.body)
|
54
71
|
validator.valid?.must_equal true
|
55
72
|
end
|
56
73
|
end
|
57
74
|
describe('when not valid') do
|
58
75
|
before do
|
59
76
|
validator_res = File.join('spec', 'data', 'validator.nu-failure.html')
|
60
|
-
stub_request(:any,
|
77
|
+
stub_request(:any, subject.html5_validator_service_url)
|
61
78
|
.to_return(body: open(validator_res).read)
|
62
79
|
name = 'html5'
|
63
80
|
file = File.join('spec', 'data', "#{name}-linuxfr.html")
|
@@ -68,17 +85,17 @@ describe ValidateWebsite::Validator do
|
|
68
85
|
end
|
69
86
|
|
70
87
|
it 'should have an array of errors' do
|
71
|
-
validator =
|
72
|
-
|
88
|
+
validator = subject.new(@html5_page.doc,
|
89
|
+
@html5_page.body)
|
73
90
|
validator.valid?.must_equal false
|
74
91
|
validator.errors.size.must_equal 38
|
75
92
|
end
|
76
93
|
|
77
94
|
it 'should exclude errors ignored by :ignore option' do
|
78
95
|
ignore = /The nowrap attribute on the td element is obsolete/
|
79
|
-
validator =
|
80
|
-
|
81
|
-
|
96
|
+
validator = subject.new(@html5_page.doc,
|
97
|
+
@html5_page.body,
|
98
|
+
ignore)
|
82
99
|
validator.valid?.must_equal false
|
83
100
|
validator.errors.size.must_equal 36
|
84
101
|
end
|
@@ -87,18 +104,18 @@ describe ValidateWebsite::Validator do
|
|
87
104
|
describe('excessive') do
|
88
105
|
before do
|
89
106
|
validator_res = File.join('spec', 'data', 'validator.nu-excessive.html')
|
90
|
-
stub_request(:any,
|
107
|
+
stub_request(:any, subject.html5_validator_service_url)
|
91
108
|
.to_return(body: open(validator_res).read)
|
92
109
|
end
|
93
|
-
it
|
110
|
+
it 'html5 should have errors' do
|
94
111
|
name = 'html5'
|
95
112
|
file = File.join('spec', 'data', "#{name}.html")
|
96
113
|
page = FakePage.new(name,
|
97
114
|
body: open(file).read,
|
98
115
|
content_type: 'text/html')
|
99
116
|
@html5_page = @http.get_page(page.url)
|
100
|
-
validator =
|
101
|
-
|
117
|
+
validator = subject.new(@html5_page.doc,
|
118
|
+
@html5_page.body)
|
102
119
|
validator.valid?.must_equal false
|
103
120
|
end
|
104
121
|
end
|
@@ -112,8 +129,8 @@ describe ValidateWebsite::Validator do
|
|
112
129
|
body: open(file).read,
|
113
130
|
content_type: 'text/html')
|
114
131
|
@html4_strict_page = @http.get_page(page.url)
|
115
|
-
validator =
|
116
|
-
|
132
|
+
validator = subject.new(@html4_strict_page.doc,
|
133
|
+
@html4_strict_page.body)
|
117
134
|
validator.valid?.must_equal true
|
118
135
|
end
|
119
136
|
end
|
data/spec/webmock_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'webmock/minitest'
|
3
3
|
|
4
|
+
# FakePage html helper for webmock
|
4
5
|
class FakePage
|
5
6
|
include WebMock::API
|
6
7
|
|
@@ -12,7 +13,7 @@ class FakePage
|
|
12
13
|
@name = name
|
13
14
|
@links = [options[:links]].flatten if options.key?(:links)
|
14
15
|
@hrefs = [options[:hrefs]].flatten if options.key?(:hrefs)
|
15
|
-
@content_type = options[:content_type] ||
|
16
|
+
@content_type = options[:content_type] || 'text/html'
|
16
17
|
@body = options[:body]
|
17
18
|
|
18
19
|
create_body unless @body
|
@@ -26,10 +27,10 @@ class FakePage
|
|
26
27
|
private
|
27
28
|
|
28
29
|
def create_body
|
29
|
-
@body =
|
30
|
+
@body = '<html><body>'
|
30
31
|
@links.each { |l| @body += "<a href=\"#{SPEC_DOMAIN}#{l}\"></a>" } if @links
|
31
32
|
@hrefs.each { |h| @body += "<a href=\"#{h}\"></a>" } if @hrefs
|
32
|
-
@body +=
|
33
|
+
@body += '</body></html>'
|
33
34
|
end
|
34
35
|
|
35
36
|
def add_to_webmock
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate-website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Arnoud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spidr
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '5.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest-line
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.6'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: webmock
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,19 +123,19 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '1.18'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: rubocop
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
131
|
+
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
138
|
+
version: '0'
|
125
139
|
description: validate-website is a web crawler for checking the markup validity with
|
126
140
|
XML Schema / DTD and not found urls.
|
127
141
|
email: laurent@spkdev.net
|
@@ -228,12 +242,16 @@ files:
|
|
228
242
|
- lib/validate_website.rb
|
229
243
|
- lib/validate_website/colorful_messages.rb
|
230
244
|
- lib/validate_website/core.rb
|
245
|
+
- lib/validate_website/crawl.rb
|
231
246
|
- lib/validate_website/option_parser.rb
|
232
247
|
- lib/validate_website/runner.rb
|
248
|
+
- lib/validate_website/static.rb
|
233
249
|
- lib/validate_website/validator.rb
|
250
|
+
- lib/validate_website/version.rb
|
234
251
|
- man/man1/validate-website-static.1
|
235
252
|
- man/man1/validate-website.1
|
236
253
|
- spec/core_spec.rb
|
254
|
+
- spec/crawler_spec.rb
|
237
255
|
- spec/data/assets/application-92f19110a9d47a56d2ebe744e15af301.css
|
238
256
|
- spec/data/html4-strict.html
|
239
257
|
- spec/data/html5-linuxfr.html
|
@@ -242,9 +260,11 @@ files:
|
|
242
260
|
- spec/data/validator.nu-excessive.html
|
243
261
|
- spec/data/validator.nu-failure.html
|
244
262
|
- spec/data/validator.nu-success.html
|
263
|
+
- spec/data/w3.org-xhtml1-strict-errors.html
|
245
264
|
- spec/data/xhtml1-strict.html
|
246
265
|
- spec/example/ruby smalltalk/blockcamp-paris-le-28-novembre.html
|
247
266
|
- spec/spec_helper.rb
|
267
|
+
- spec/static_spec.rb
|
248
268
|
- spec/validator_spec.rb
|
249
269
|
- spec/webmock_helper.rb
|
250
270
|
homepage: http://github.com/spk/validate-website
|
@@ -270,11 +290,13 @@ requirements:
|
|
270
290
|
- rainbow
|
271
291
|
- multipart_body
|
272
292
|
rubyforge_project:
|
273
|
-
rubygems_version: 2.
|
293
|
+
rubygems_version: 2.4.5
|
274
294
|
signing_key:
|
275
295
|
specification_version: 4
|
276
296
|
summary: Web crawler for checking the validity of your documents
|
277
297
|
test_files:
|
298
|
+
- spec/static_spec.rb
|
278
299
|
- spec/core_spec.rb
|
300
|
+
- spec/crawler_spec.rb
|
279
301
|
- spec/validator_spec.rb
|
280
302
|
has_rdoc:
|