site-inspector 3.1.0 → 3.1.1

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +34 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +1 -1
  5. data/Guardfile +1 -1
  6. data/README.md +6 -1
  7. data/Rakefile +2 -2
  8. data/bin/site-inspector +15 -15
  9. data/lib/cliver/dependency_ext.rb +21 -0
  10. data/lib/site-inspector.rb +13 -11
  11. data/lib/site-inspector/checks/accessibility.rb +27 -17
  12. data/lib/site-inspector/checks/check.rb +1 -3
  13. data/lib/site-inspector/checks/content.rb +6 -6
  14. data/lib/site-inspector/checks/cookies.rb +6 -8
  15. data/lib/site-inspector/checks/dns.rb +21 -20
  16. data/lib/site-inspector/checks/headers.rb +12 -13
  17. data/lib/site-inspector/checks/hsts.rb +8 -9
  18. data/lib/site-inspector/checks/https.rb +3 -5
  19. data/lib/site-inspector/checks/sniffer.rb +8 -9
  20. data/lib/site-inspector/domain.rb +28 -32
  21. data/lib/site-inspector/endpoint.rb +31 -32
  22. data/lib/site-inspector/version.rb +1 -1
  23. data/script/cibuild +3 -1
  24. data/script/pa11y-version +9 -0
  25. data/site-inspector.gemspec +25 -25
  26. data/spec/checks/site_inspector_endpoint_accessibility_spec.rb +31 -30
  27. data/spec/checks/site_inspector_endpoint_check_spec.rb +10 -11
  28. data/spec/checks/site_inspector_endpoint_content_spec.rb +43 -44
  29. data/spec/checks/site_inspector_endpoint_cookies_spec.rb +30 -31
  30. data/spec/checks/site_inspector_endpoint_dns_spec.rb +72 -77
  31. data/spec/checks/site_inspector_endpoint_headers_spec.rb +26 -27
  32. data/spec/checks/site_inspector_endpoint_hsts_spec.rb +26 -27
  33. data/spec/checks/site_inspector_endpoint_https_spec.rb +11 -12
  34. data/spec/checks/site_inspector_endpoint_sniffer_spec.rb +56 -57
  35. data/spec/site_inspector_cache_spec.rb +6 -6
  36. data/spec/site_inspector_disk_cache_spec.rb +9 -9
  37. data/spec/site_inspector_domain_spec.rb +132 -136
  38. data/spec/site_inspector_endpoint_spec.rb +108 -108
  39. data/spec/site_inspector_spec.rb +17 -18
  40. data/spec/spec_helper.rb +3 -3
  41. metadata +21 -3
@@ -1,100 +1,99 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SiteInspector::Endpoint do
4
+
5
+ subject { SiteInspector::Endpoint.new('http://example.com') }
4
6
 
5
- subject { SiteInspector::Endpoint.new("http://example.com") }
6
-
7
- it "downcases the host" do
8
- endpoint = SiteInspector::Endpoint.new("http://EXAMPLE.com")
9
- expect(endpoint.host).to eql("example.com")
7
+ it 'downcases the host' do
8
+ endpoint = SiteInspector::Endpoint.new('http://EXAMPLE.com')
9
+ expect(endpoint.host).to eql('example.com')
10
10
  end
11
11
 
12
- it "strips www from the host" do
13
- endpoint = SiteInspector::Endpoint.new("http://www.example.com")
14
- expect(endpoint.host).to eql("example.com")
12
+ it 'strips www from the host' do
13
+ endpoint = SiteInspector::Endpoint.new('http://www.example.com')
14
+ expect(endpoint.host).to eql('example.com')
15
15
  end
16
16
 
17
- it "returns the uri" do
18
- expect(subject.uri.to_s).to eql("http://example.com/")
17
+ it 'returns the uri' do
18
+ expect(subject.uri.to_s).to eql('http://example.com/')
19
19
  end
20
20
 
21
- it "knows if an endpoint is www" do
21
+ it 'knows if an endpoint is www' do
22
22
  expect(subject.www?).to eql(false)
23
23
  expect(subject.root?).to eql(true)
24
24
 
25
- endpoint = SiteInspector::Endpoint.new("http://www.example.com")
25
+ endpoint = SiteInspector::Endpoint.new('http://www.example.com')
26
26
  expect(endpoint.www?).to eql(true)
27
27
  expect(endpoint.root?).to eql(false)
28
28
  end
29
29
 
30
- it "knows if an endpoint is http" do
31
- stub_request(:head, "http://example.com/").
32
- to_return(:status => 200, :body => "content")
30
+ it 'knows if an endpoint is http' do
31
+ stub_request(:head, 'http://example.com/')
32
+ .to_return(status: 200, body: 'content')
33
33
 
34
- stub_request(:head, "https://example.com/").
35
- to_return(:status => 500, :body => "content")
34
+ stub_request(:head, 'https://example.com/')
35
+ .to_return(status: 500, body: 'content')
36
36
 
37
37
  expect(subject.https?).to eql(false)
38
38
  expect(subject.http?).to eql(true)
39
39
  end
40
40
 
41
- it "knows if an endpoint is https" do
42
- stub_request(:head, "http://example.com/").
43
- to_return(:status => 200, :body => "content")
41
+ it 'knows if an endpoint is https' do
42
+ stub_request(:head, 'http://example.com/')
43
+ .to_return(status: 200, body: 'content')
44
44
 
45
- stub_request(:head, "https://example.com/").
46
- to_return(:status => 200, :body => "content")
45
+ stub_request(:head, 'https://example.com/')
46
+ .to_return(status: 200, body: 'content')
47
47
 
48
- endpoint = SiteInspector::Endpoint.new("https://example.com")
48
+ endpoint = SiteInspector::Endpoint.new('https://example.com')
49
49
  expect(endpoint.https?).to eql(true)
50
50
  expect(endpoint.http?).to eql(false)
51
51
  end
52
52
 
53
- it "knows the scheme" do
54
- expect(subject.scheme).to eql("http")
53
+ it 'knows the scheme' do
54
+ expect(subject.scheme).to eql('http')
55
55
 
56
- endpoint = SiteInspector::Endpoint.new("https://example.com")
57
- expect(endpoint.scheme).to eql("https")
56
+ endpoint = SiteInspector::Endpoint.new('https://example.com')
57
+ expect(endpoint.scheme).to eql('https')
58
58
  end
59
59
 
60
- context "requests" do
61
-
62
- it "requests a URL" do
63
- stub = stub_request(:head, "http://example.com/").
64
- to_return(:status => 200, :body => "content")
60
+ context 'requests' do
61
+ it 'requests a URL' do
62
+ stub = stub_request(:head, 'http://example.com/')
63
+ .to_return(status: 200, body: 'content')
65
64
 
66
- expect(subject.request.body).to eql("content")
65
+ expect(subject.request.body).to eql('content')
67
66
  expect(stub).to have_been_requested
68
67
  end
69
68
 
70
- it "requests a requested path" do
71
- stub = stub_request(:head, "http://example.com/foo").
72
- to_return(:status => 200, :body => "content")
69
+ it 'requests a requested path' do
70
+ stub = stub_request(:head, 'http://example.com/foo')
71
+ .to_return(status: 200, body: 'content')
73
72
 
74
- expect(subject.request(:path => "foo").body).to eql("content")
73
+ expect(subject.request(path: 'foo').body).to eql('content')
75
74
  expect(stub).to have_been_requested
76
75
  end
77
76
 
78
- it "requests with typhoeus options" do
79
- stub_request(:head, "http://example.com/").
80
- to_return(:status => 301, :headers => { :location => "http://example.com/foo" } )
77
+ it 'requests with typhoeus options' do
78
+ stub_request(:head, 'http://example.com/')
79
+ .to_return(status: 301, headers: { location: 'http://example.com/foo' })
81
80
 
82
- response = subject.request(:followlocation => true)
81
+ response = subject.request(followlocation: true)
83
82
  expect(response.request.options[:followlocation]).to eql(true)
84
83
  end
85
84
 
86
- it "returns the response" do
87
- stub = stub_request(:head, "http://example.com/").
88
- to_return(:status => 200, :body => "content")
85
+ it 'returns the response' do
86
+ stub = stub_request(:head, 'http://example.com/')
87
+ .to_return(status: 200, body: 'content')
89
88
 
90
- expect(subject.response.body).to eql("content")
91
- expect(subject.response.body).to eql("content")
89
+ expect(subject.response.body).to eql('content')
90
+ expect(subject.response.body).to eql('content')
92
91
  expect(stub).to have_been_requested.once
93
92
  end
94
93
 
95
94
  it "knows if there's a response" do
96
- stub_request(:head, "http://example.com/").
97
- to_return(:status => 200, :body => "content")
95
+ stub_request(:head, 'http://example.com/')
96
+ .to_return(status: 200, body: 'content')
98
97
 
99
98
  expect(subject.responds?).to eql(true)
100
99
  end
@@ -103,148 +102,149 @@ describe SiteInspector::Endpoint do
103
102
  allow(subject).to receive(:response) { Typhoeus::Response.new(code: 0) }
104
103
  expect(subject.responds?).to eql(false)
105
104
 
106
- allow(subject).to receive(:response) { Typhoeus::Response.new(:return_code => :operation_timedout) }
105
+ allow(subject).to receive(:response) { Typhoeus::Response.new(return_code: :operation_timedout) }
107
106
  expect(subject.responds?).to eql(false)
108
107
  end
109
108
 
110
- it "knows the response code" do
111
- stub_request(:head, "http://example.com/").
112
- to_return(:status => 200)
109
+ it 'knows the response code' do
110
+ stub_request(:head, 'http://example.com/')
111
+ .to_return(status: 200)
113
112
 
114
- expect(subject.response_code).to eql("200")
113
+ expect(subject.response_code).to eql('200')
115
114
  end
116
115
 
117
- it "knows if a response has timed out" do
118
- allow(subject).to receive(:response) { Typhoeus::Response.new(:return_code => :operation_timedout) }
116
+ it 'knows if a response has timed out' do
117
+ allow(subject).to receive(:response) { Typhoeus::Response.new(return_code: :operation_timedout) }
119
118
  expect(subject.timed_out?).to eql(true)
120
119
  end
121
120
 
122
- it "considers a 200 response code to be live and a response" do
123
- stub_request(:head, "http://example.com/").
124
- to_return(:status => 200)
121
+ it 'considers a 200 response code to be live and a response' do
122
+ stub_request(:head, 'http://example.com/')
123
+ .to_return(status: 200)
125
124
 
126
125
  expect(subject.up?).to eql(true)
127
126
  expect(subject.responds?).to eql(true)
128
127
  end
129
128
 
130
- it "considers a 301 response code to be live and a response" do
131
- stub_request(:head, "http://example.com/").
132
- to_return(:status => 301)
129
+ it 'considers a 301 response code to be live and a response' do
130
+ stub_request(:head, 'http://example.com/')
131
+ .to_return(status: 301)
133
132
 
134
133
  expect(subject.up?).to eql(true)
135
134
  expect(subject.responds?).to eql(true)
136
135
  end
137
136
 
138
- it "considers a 404 response code to be down but a response" do
139
- stub_request(:head, "http://example.com/").
140
- to_return(:status => 404)
137
+ it 'considers a 404 response code to be down but a response' do
138
+ stub_request(:head, 'http://example.com/')
139
+ .to_return(status: 404)
141
140
 
142
141
  expect(subject.up?).to eql(false)
143
142
  expect(subject.responds?).to eql(true)
144
143
  end
145
144
 
146
- it "considers a 500 response code to be down but a response" do
147
- stub_request(:head, "http://example.com/").
148
- to_return(:status => 500)
145
+ it 'considers a 500 response code to be down but a response' do
146
+ stub_request(:head, 'http://example.com/')
147
+ .to_return(status: 500)
149
148
 
150
149
  expect(subject.up?).to eql(false)
151
150
  expect(subject.responds?).to eql(true)
152
151
  end
153
152
 
154
- it "considers a 0 response code (error) to down and unresponsive" do
153
+ it 'considers a 0 response code (error) to down and unresponsive' do
155
154
  allow(subject).to receive(:response) { Typhoeus::Response.new(code: 0) }
156
155
 
157
156
  expect(subject.up?).to eql(false)
158
157
  expect(subject.responds?).to eql(false)
159
158
  end
160
159
 
161
- it "considers a timeout to be down and unresponsive" do
162
- allow(subject).to receive(:response) { Typhoeus::Response.new(:return_code => :operation_timedout) }
160
+ it 'considers a timeout to be down and unresponsive' do
161
+ allow(subject).to receive(:response) { Typhoeus::Response.new(return_code: :operation_timedout) }
163
162
 
164
163
  expect(subject.up?).to eql(false)
165
164
  expect(subject.responds?).to eql(false)
166
165
  end
167
166
  end
168
167
 
169
- context "redirects" do
168
+ context 'redirects' do
170
169
  it "knows when there's a redirect" do
171
- stub_request(:head, "http://example.com/").
172
- to_return(:status => 301, :headers => { :location => "http://www.example.com" } )
170
+ stub_request(:head, 'http://example.com/')
171
+ .to_return(status: 301, headers: { location: 'http://www.example.com' })
173
172
 
174
173
  expect(subject.redirect?).to eql(true)
175
174
  end
176
175
 
177
- it "returns the redirect" do
178
- stub_request(:head, "http://example.com/").
179
- to_return(:status => 301, :headers => { :location => "http://www.example.com" } )
176
+ it 'returns the redirect' do
177
+ stub_request(:head, 'http://example.com/')
178
+ .to_return(status: 301, headers: { location: 'http://www.example.com' })
180
179
 
181
- stub_request(:head, "http://www.example.com/").
182
- to_return(:status => 200)
180
+ stub_request(:head, 'http://www.example.com/')
181
+ .to_return(status: 200)
183
182
 
184
- expect(subject.redirect.uri.to_s).to eql("http://www.example.com/")
183
+ expect(subject.redirect.uri.to_s).to eql('http://www.example.com/')
185
184
  end
186
185
 
187
- it "handles relative redirects" do
188
- stub_request(:head, "http://example.com/").
189
- to_return(:status => 301, :headers => { :location => "/foo" } )
186
+ it 'handles relative redirects' do
187
+ stub_request(:head, 'http://example.com/')
188
+ .to_return(status: 301, headers: { location: '/foo' })
190
189
 
191
190
  expect(subject.redirect?).to eql(false)
192
191
  end
193
192
 
194
- it "handles relative redirects without a leading slash" do
195
- stub_request(:head, "http://example.com/").
196
- to_return(:status => 301, :headers => { :location => "foo" } )
193
+ it 'handles relative redirects without a leading slash' do
194
+ stub_request(:head, 'http://example.com/')
195
+ .to_return(status: 301, headers: { location: 'foo' })
197
196
 
198
197
  expect(subject.redirect?).to eql(false)
199
198
  end
200
199
 
201
- it "knows what it resolves to" do
202
- stub_request(:head, "http://example.com/").
203
- to_return(:status => 301, :headers => { :location => "http://www.example.com" } )
200
+ it 'knows what it resolves to' do
201
+ stub_request(:head, 'http://example.com/')
202
+ .to_return(status: 301, headers: { location: 'http://www.example.com' })
204
203
 
205
- stub_request(:head, "http://www.example.com/").
206
- to_return(:status => 200)
204
+ stub_request(:head, 'http://www.example.com/')
205
+ .to_return(status: 200)
207
206
 
208
207
  expect(subject.redirect?).to eql(true)
209
- expect(subject.resolves_to.uri.to_s).to eql("http://www.example.com/")
208
+ expect(subject.resolves_to.uri.to_s).to eql('http://www.example.com/')
210
209
  end
211
210
 
212
- it "detects external redirects" do
213
- stub_request(:head, "http://example.com/").
214
- to_return(:status => 301, :headers => { :location => "http://www.example.gov" } )
211
+ it 'detects external redirects' do
212
+ stub_request(:head, 'http://example.com/')
213
+ .to_return(status: 301, headers: { location: 'http://www.example.gov' })
215
214
 
216
- stub_request(:head, "http://www.example.gov").
217
- to_return(:status => 200)
215
+ stub_request(:head, 'http://www.example.gov')
216
+ .to_return(status: 200)
218
217
 
219
218
  expect(subject.redirect?).to eql(true)
220
219
  expect(subject.external_redirect?).to eql(true)
221
220
  end
222
221
 
223
- it "knows internal redirects are not external redirects" do
224
- stub_request(:head, "http://example.com/").
225
- to_return(:status => 301, :headers => { :location => "https://example.com" } )
222
+ it 'knows internal redirects are not external redirects' do
223
+ stub_request(:head, 'http://example.com/')
224
+ .to_return(status: 301, headers: { location: 'https://example.com' })
226
225
 
227
- stub_request(:head, "https://example.com/").
228
- to_return(:status => 200)
226
+ stub_request(:head, 'https://example.com/')
227
+ .to_return(status: 200)
229
228
 
230
229
  expect(subject.external_redirect?).to eql(false)
231
230
  end
232
231
  end
233
232
 
234
- context "checks" do
235
- it "identifies checks" do
236
- expect(SiteInspector::Endpoint.checks.count).to eql(8)
233
+ context 'checks' do
234
+ it 'identifies checks' do
235
+ expected = 8
236
+ pa11y = SiteInspector::Endpoint::Accessibility.pa11y?
237
+ expected -= 1 unless pa11y
238
+ expect(SiteInspector::Endpoint.checks.count).to eql(expected)
237
239
  end
238
240
 
239
241
  SiteInspector::Endpoint.checks.each do |check|
240
242
  it "responds to the #{check} check" do
241
-
242
- stub_request(:head, "http://example.com/").
243
- to_return(:status => 200)
243
+ stub_request(:head, 'http://example.com/')
244
+ .to_return(status: 200)
244
245
 
245
246
  expect(subject.send(check.name)).to_not be_nil
246
247
  expect(subject.send(check.name).class).to eql(check)
247
-
248
248
  end
249
249
  end
250
250
  end
@@ -1,45 +1,44 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SiteInspector do
4
-
5
4
  before do
6
- SiteInspector.instance_variable_set("@cache", nil)
7
- SiteInspector.instance_variable_set("@timeout", nil)
5
+ SiteInspector.instance_variable_set('@cache', nil)
6
+ SiteInspector.instance_variable_set('@timeout', nil)
8
7
  end
9
8
 
10
- it "defaults to ephemeral cache" do
11
- with_env "CACHE", nil do
9
+ it 'defaults to ephemeral cache' do
10
+ with_env 'CACHE', nil do
12
11
  expect(SiteInspector.cache.class).to be(SiteInspector::Cache)
13
12
  end
14
13
  end
15
14
 
16
- it "uses disk cache when requested" do
17
- with_env "CACHE", "/tmp" do
15
+ it 'uses disk cache when requested' do
16
+ with_env 'CACHE', '/tmp' do
18
17
  expect(SiteInspector.cache.class).to be(SiteInspector::DiskCache)
19
18
  end
20
19
  end
21
20
 
22
- it "returns the default timeout" do
21
+ it 'returns the default timeout' do
23
22
  expect(SiteInspector.timeout).to eql(10)
24
23
  end
25
24
 
26
- it "honors custom timeouts" do
25
+ it 'honors custom timeouts' do
27
26
  SiteInspector.timeout = 20
28
27
  expect(SiteInspector.timeout).to eql(20)
29
28
  end
30
29
 
31
- it "returns a domain when inspecting" do
32
- expect(SiteInspector.inspect("example.com").class).to be(SiteInspector::Domain)
30
+ it 'returns a domain when inspecting' do
31
+ expect(SiteInspector.inspect('example.com').class).to be(SiteInspector::Domain)
33
32
  end
34
33
 
35
- it "returns the typhoeus defaults" do
34
+ it 'returns the typhoeus defaults' do
36
35
  expected = {
37
- :accept_encoding => "gzip",
38
- :followlocation => false,
39
- :method => :head,
40
- :timeout => 10,
41
- :headers => {
42
- "User-Agent" => "Mozilla/5.0 (compatible; SiteInspector/#{SiteInspector::VERSION}; +https://github.com/benbalter/site-inspector)"
36
+ accept_encoding: 'gzip',
37
+ followlocation: false,
38
+ method: :head,
39
+ timeout: 10,
40
+ headers: {
41
+ 'User-Agent' => "Mozilla/5.0 (compatible; SiteInspector/#{SiteInspector::VERSION}; +https://github.com/benbalter/site-inspector)"
43
42
  }
44
43
  }
45
44
  expect(SiteInspector.typhoeus_defaults).to eql(expected)
@@ -1,7 +1,7 @@
1
- require "bundler/setup"
1
+ require 'bundler/setup'
2
2
  require 'webmock/rspec'
3
3
  require 'fileutils'
4
- require_relative "../lib/site-inspector"
4
+ require_relative '../lib/site-inspector'
5
5
 
6
6
  WebMock.disable_net_connect!
7
7
 
@@ -13,5 +13,5 @@ def with_env(key, value)
13
13
  end
14
14
 
15
15
  def tmpdir
16
- File.expand_path "../tmp", File.dirname(__FILE__)
16
+ File.expand_path '../tmp', File.dirname(__FILE__)
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site-inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: '1.2'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '0.35'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '0.35'
237
251
  description: Returns information about a domain's technology and capabilities
238
252
  email: ben@balter.com
239
253
  executables:
@@ -242,6 +256,7 @@ extensions: []
242
256
  extra_rdoc_files: []
243
257
  files:
244
258
  - ".gitignore"
259
+ - ".rubocop.yml"
245
260
  - ".ruby-version"
246
261
  - ".travis.yml"
247
262
  - Gemfile
@@ -250,6 +265,7 @@ files:
250
265
  - README.md
251
266
  - Rakefile
252
267
  - bin/site-inspector
268
+ - lib/cliver/dependency_ext.rb
253
269
  - lib/data/cdn.yml
254
270
  - lib/data/cloud.yml
255
271
  - lib/site-inspector.rb
@@ -272,6 +288,7 @@ files:
272
288
  - script/bootstrap
273
289
  - script/cibuild
274
290
  - script/console
291
+ - script/pa11y-version
275
292
  - script/release
276
293
  - site-inspector.gemspec
277
294
  - spec/checks/site_inspector_endpoint_accessibility_spec.rb
@@ -309,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
326
  version: '0'
310
327
  requirements: []
311
328
  rubyforge_project:
312
- rubygems_version: 2.2.2
329
+ rubygems_version: 2.5.1
313
330
  signing_key:
314
331
  specification_version: 4
315
332
  summary: A Ruby port and v2 of Site Inspector (https://github.com/benbalter/site-inspector)
@@ -329,3 +346,4 @@ test_files:
329
346
  - spec/site_inspector_endpoint_spec.rb
330
347
  - spec/site_inspector_spec.rb
331
348
  - spec/spec_helper.rb
349
+ has_rdoc: