validate-website 1.9.1 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('test_helper', __dir__)
2
4
 
3
5
  # rubocop:disable Metrics/BlockLength
@@ -17,7 +19,7 @@ describe ValidateWebsite::Static do
17
19
  not_found: false,
18
20
  exclude: /data|example/)
19
21
  end
20
- @validate_website.history_count.must_equal 0
22
+ _(@validate_website.history_count).must_equal 0
21
23
  end
22
24
 
23
25
  it 'no space in directory name' do
@@ -28,7 +30,7 @@ describe ValidateWebsite::Static do
28
30
  markup: false,
29
31
  not_found: false)
30
32
  end
31
- @validate_website.not_founds_count.must_equal 0
33
+ _(@validate_website.not_founds_count).must_equal 0
32
34
  end
33
35
 
34
36
  it 'not found' do
@@ -40,7 +42,25 @@ describe ValidateWebsite::Static do
40
42
  markup: false,
41
43
  not_found: true)
42
44
  end
43
- @validate_website.not_founds_count.must_equal 213
45
+ _(@validate_website.not_founds_count).must_equal 213
46
+ end
47
+ end
48
+
49
+ it 'can change validator' do
50
+ validator_res = File.join('test', 'data', 'validator.nu-failure.json')
51
+ stub_request(:any,
52
+ /#{ValidateWebsite::Validator.html5_validator_service_url}/)
53
+ .to_return(body: File.open(validator_res).read)
54
+ pattern = File.join(File.dirname(__FILE__), 'data',
55
+ 'html5-fail.html')
56
+ Dir.chdir('test/data') do
57
+ _out, _err = capture_io do
58
+ @validate_website.crawl(pattern: pattern,
59
+ site: 'http://w3.org/',
60
+ ignore: /Warning/,
61
+ html5_validator: :nu)
62
+ end
63
+ _(@validate_website.errors_count).must_equal 1
44
64
  end
45
65
  end
46
66
 
@@ -53,7 +73,7 @@ describe ValidateWebsite::Static do
53
73
  site: 'http://w3.org/',
54
74
  ignore: /height|width|Length/)
55
75
  end
56
- @validate_website.errors_count.must_equal 0
76
+ _(@validate_website.errors_count).must_equal 0
57
77
  end
58
78
  end
59
79
 
@@ -67,7 +87,7 @@ describe ValidateWebsite::Static do
67
87
  markup: false,
68
88
  css_syntax: true)
69
89
  end
70
- @validate_website.errors_count.must_equal 1
90
+ _(@validate_website.errors_count).must_equal 1
71
91
  end
72
92
  end
73
93
  end
@@ -1,19 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  begin
4
- require 'coveralls'
5
- Coveralls.wear!
4
+ require 'simplecov'
5
+ SimpleCov.start
6
6
  rescue LoadError
7
- STDERR.puts 'coveralls not loaded'
7
+ warn 'simplecov not loaded'
8
8
  end
9
9
 
10
10
  require 'minitest/autorun'
11
- require 'minitest/focus'
12
11
  require 'spidr'
13
12
 
14
13
  require 'validate_website/core'
15
14
 
16
15
  require File.expand_path('webmock_helper', __dir__)
17
16
 
18
- TEST_DOMAIN = 'http://www.example.com/'.freeze
17
+ TEST_DOMAIN = 'http://www.example.com/'
19
18
  ENV['LC_ALL'] = 'C.UTF-8' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('test_helper', __dir__)
2
4
 
3
5
  # rubocop:disable Metrics/BlockLength
@@ -14,15 +16,15 @@ describe ValidateWebsite::Validator do
14
16
  name = 'w3.org-xhtml1-strict-errors'
15
17
  file = File.join('test', 'data', "#{name}.html")
16
18
  page = FakePage.new(name,
17
- body: open(file).read,
19
+ body: File.open(file).read,
18
20
  content_type: 'text/html')
19
21
  @xhtml1_page = @http.get_page(page.url)
20
22
  ignore = /width|height|Length/
21
23
  validator = subject.new(@xhtml1_page.doc,
22
24
  @xhtml1_page.body,
23
25
  ignore: ignore)
24
- validator.valid?.must_equal true
25
- validator.errors.must_equal []
26
+ _(validator.valid?).must_equal true
27
+ _(validator.errors).must_equal []
26
28
  end
27
29
 
28
30
  it 'xhtml1-strict should be valid' do
@@ -30,17 +32,17 @@ describe ValidateWebsite::Validator do
30
32
  dtd_uri = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
31
33
  file = File.join('test', 'data', "#{name}.html")
32
34
  page = FakePage.new(name,
33
- body: open(file).read,
35
+ body: File.open(file).read,
34
36
  content_type: 'text/html')
35
37
  @xhtml1_page = @http.get_page(page.url)
36
38
  ignore = /width|height|Length/
37
39
  validator = subject.new(@xhtml1_page.doc,
38
40
  @xhtml1_page.body,
39
41
  ignore: ignore)
40
- validator.dtd.system_id.must_equal dtd_uri
41
- validator.namespace.must_equal name
42
- validator.valid?.must_equal true
43
- validator.errors.must_equal []
42
+ _(validator.dtd.system_id).must_equal dtd_uri
43
+ _(validator.namespace).must_equal name
44
+ _(validator.valid?).must_equal true
45
+ _(validator.errors).must_equal []
44
46
  end
45
47
  end
46
48
 
@@ -49,18 +51,18 @@ describe ValidateWebsite::Validator do
49
51
  before do
50
52
  validator_res = File.join('test', 'data', 'validator.nu-success.json')
51
53
  stub_request(:any, /#{subject.html5_validator_service_url}/)
52
- .to_return(body: open(validator_res).read)
54
+ .to_return(body: File.open(validator_res).read)
53
55
  end
54
56
  it 'html5 should be valid' do
55
57
  name = 'html5'
56
58
  file = File.join('test', 'data', "#{name}.html")
57
59
  page = FakePage.new(name,
58
- body: open(file).read,
60
+ body: File.open(file).read,
59
61
  content_type: 'text/html')
60
62
  @html5_page = @http.get_page(page.url)
61
63
  validator = subject.new(@html5_page.doc,
62
64
  @html5_page.body)
63
- validator.valid?.must_equal true
65
+ _(validator.valid?).must_equal true
64
66
  end
65
67
  end
66
68
 
@@ -68,22 +70,22 @@ describe ValidateWebsite::Validator do
68
70
  before do
69
71
  validator_res = File.join('test', 'data', 'validator.nu-failure.json')
70
72
  stub_request(:any, /#{subject.html5_validator_service_url}/)
71
- .to_return(body: open(validator_res).read)
73
+ .to_return(body: File.open(validator_res).read)
72
74
  name = 'html5-fail'
73
75
  file = File.join('test', 'data', "#{name}.html")
74
76
  page = FakePage.new(name,
75
- body: open(file).read,
77
+ body: File.open(file).read,
76
78
  content_type: 'text/html')
77
79
  @html5_page = @http.get_page(page.url)
78
80
  end
79
81
 
80
- describe('without tidy') do
82
+ describe('with nu') do
81
83
  it 'should have an array of errors' do
82
84
  validator = subject.new(@html5_page.doc,
83
85
  @html5_page.body,
84
86
  html5_validator: :nu)
85
- validator.valid?.must_equal false
86
- validator.errors.size.must_equal 3
87
+ _(validator.valid?).must_equal false
88
+ _(validator.errors.size).must_equal 3
87
89
  end
88
90
 
89
91
  it 'should exclude errors ignored by :ignore option' do
@@ -92,26 +94,50 @@ describe ValidateWebsite::Validator do
92
94
  @html5_page.body,
93
95
  ignore: ignore,
94
96
  html5_validator: :nu)
95
- validator.valid?.must_equal false
96
- validator.errors.size.must_equal 1
97
+ _(validator.valid?).must_equal false
98
+ _(validator.errors.size).must_equal 1
99
+ end
100
+ end
101
+
102
+ describe('with nokogumbo') do
103
+ it 'have an array of errors' do
104
+ skip('nokogumbo dont support jruby') if ValidateWebsite.jruby?
105
+ validator = subject.new(@html5_page.doc,
106
+ @html5_page.body,
107
+ html5_validator: :nokogumbo)
108
+ _(validator.valid?).must_equal false
109
+ _(validator.errors.size).must_equal 1
110
+ end
111
+
112
+ it 'exclude errors ignored by :ignore option' do
113
+ skip('nokogumbo dont support jruby') if ValidateWebsite.jruby?
114
+ ignore = /That tag isn't allowed here/
115
+ validator = subject.new(@html5_page.doc,
116
+ @html5_page.body,
117
+ ignore: ignore,
118
+ html5_validator: :nokogumbo)
119
+ _(validator.valid?).must_equal true
120
+ _(validator.errors.size).must_equal 0
97
121
  end
98
122
  end
99
123
 
100
124
  describe('with tidy') do
101
125
  it 'should have an array of errors' do
126
+ skip('tidy is not installed') unless ValidateWebsite::Validator.tidy
102
127
  validator = subject.new(@html5_page.doc,
103
128
  @html5_page.body)
104
- validator.valid?.must_equal false
105
- validator.errors.size.must_equal 4
129
+ _(validator.valid?).must_equal false
130
+ _(validator.errors.size).must_equal 3
106
131
  end
107
132
 
108
133
  it 'should exclude errors ignored by :ignore option' do
134
+ skip('tidy is not installed') unless ValidateWebsite::Validator.tidy
109
135
  ignore = /letter not allowed here|trimming empty/
110
136
  validator = subject.new(@html5_page.doc,
111
137
  @html5_page.body,
112
138
  ignore: ignore)
113
- validator.valid?.must_equal false
114
- validator.errors.size.must_equal 2
139
+ _(validator.valid?).must_equal false
140
+ _(validator.errors.size).must_equal 2
115
141
  end
116
142
  end
117
143
  end
@@ -122,13 +148,13 @@ describe ValidateWebsite::Validator do
122
148
  name = 'html4-strict'
123
149
  file = File.join('test', 'data', "#{name}.html")
124
150
  page = FakePage.new(name,
125
- body: open(file).read,
151
+ body: File.open(file).read,
126
152
  content_type: 'text/html')
127
153
  @html4_strict_page = @http.get_page(page.url)
128
154
  validator = subject.new(@html4_strict_page.doc,
129
155
  @html4_strict_page.body)
130
156
  validator.valid?
131
- validator.errors.must_equal []
157
+ _(validator.errors).must_equal []
132
158
  end
133
159
  end
134
160
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'webmock/minitest'
2
4
 
3
5
  # FakePage html helper for webmock
@@ -27,8 +29,8 @@ class FakePage
27
29
 
28
30
  def create_body
29
31
  @body = '<html><body>'
30
- @links.each { |l| @body += "<a href=\"#{TEST_DOMAIN}#{l}\"></a>" } if @links
31
- @hrefs.each { |h| @body += "<a href=\"#{h}\"></a>" } if @hrefs
32
+ @links&.each { |l| @body += "<a href=\"#{TEST_DOMAIN}#{l}\"></a>" }
33
+ @hrefs&.each { |h| @body += "<a href=\"#{h}\"></a>" }
32
34
  @body += '</body></html>'
33
35
  end
34
36
 
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.9.1
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Arnoud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2021-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crass
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogumbo
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: paint
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0.1'
89
+ version: '1.0'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0.1'
96
+ version: '1.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: w3c_validators
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -95,47 +109,47 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '1.3'
97
111
  - !ruby/object:Gem::Dependency
98
- name: asciidoctor
112
+ name: webrick
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '1.5'
104
- type: :development
117
+ version: '1'
118
+ type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '1.5'
124
+ version: '1'
111
125
  - !ruby/object:Gem::Dependency
112
- name: minitest
126
+ name: asciidoctor
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '5'
131
+ version: '1.5'
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: '5'
138
+ version: '1.5'
125
139
  - !ruby/object:Gem::Dependency
126
- name: minitest-focus
140
+ name: minitest
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '1'
145
+ version: '5.0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: '1'
152
+ version: '5.0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rake
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +170,14 @@ dependencies:
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: 0.58.0
173
+ version: 0.76.0
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: 0.58.0
180
+ version: 0.76.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: webmock
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -273,15 +287,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
273
287
  requirements:
274
288
  - - ">="
275
289
  - !ruby/object:Gem::Version
276
- version: 2.2.0
290
+ version: '2.5'
277
291
  required_rubygems_version: !ruby/object:Gem::Requirement
278
292
  requirements:
279
293
  - - ">="
280
294
  - !ruby/object:Gem::Version
281
295
  version: '0'
282
296
  requirements: []
283
- rubyforge_project:
284
- rubygems_version: 2.7.6
297
+ rubygems_version: 3.2.0.rc.2
285
298
  signing_key:
286
299
  specification_version: 4
287
300
  summary: Web crawler for checking the validity of your documents