site-inspector 3.1.1 → 3.2.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 +5 -5
- data/.gitignore +1 -1
- data/.rubocop.yml +18 -10
- data/.rubocop_todo.yml +139 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -0
- data/Guardfile +2 -0
- data/Rakefile +2 -0
- data/bin/site-inspector +7 -6
- data/lib/cliver/dependency_ext.rb +6 -3
- data/lib/site-inspector.rb +18 -11
- data/lib/site-inspector/cache.rb +2 -0
- data/lib/site-inspector/checks/accessibility.rb +30 -22
- data/lib/site-inspector/checks/check.rb +4 -2
- data/lib/site-inspector/checks/content.rb +15 -4
- data/lib/site-inspector/checks/cookies.rb +5 -3
- data/lib/site-inspector/checks/dns.rb +13 -11
- data/lib/site-inspector/checks/headers.rb +8 -6
- data/lib/site-inspector/checks/hsts.rb +16 -12
- data/lib/site-inspector/checks/https.rb +3 -1
- data/lib/site-inspector/checks/sniffer.rb +10 -7
- data/lib/site-inspector/checks/wappalyzer.rb +62 -0
- data/lib/site-inspector/checks/whois.rb +36 -0
- data/lib/site-inspector/disk_cache.rb +2 -0
- data/lib/site-inspector/domain.rb +36 -30
- data/lib/site-inspector/endpoint.rb +22 -23
- data/lib/site-inspector/rails_cache.rb +2 -0
- data/lib/site-inspector/version.rb +3 -1
- data/package-lock.json +505 -0
- data/package.json +1 -1
- data/script/pa11y-version +1 -0
- data/site-inspector.gemspec +24 -17
- data/spec/checks/site_inspector_endpoint_accessibility_spec.rb +15 -13
- data/spec/checks/site_inspector_endpoint_check_spec.rb +9 -7
- data/spec/checks/site_inspector_endpoint_content_spec.rb +30 -21
- data/spec/checks/site_inspector_endpoint_cookies_spec.rb +17 -15
- data/spec/checks/site_inspector_endpoint_dns_spec.rb +42 -40
- data/spec/checks/site_inspector_endpoint_headers_spec.rb +12 -10
- data/spec/checks/site_inspector_endpoint_hsts_spec.rb +27 -25
- data/spec/checks/site_inspector_endpoint_https_spec.rb +12 -10
- data/spec/checks/site_inspector_endpoint_sniffer_spec.rb +33 -31
- data/spec/checks/site_inspector_endpoint_wappalyzer_spec.rb +34 -0
- data/spec/checks/site_inspector_endpoint_whois_spec.rb +26 -0
- data/spec/fixtures/wappalyzer.json +125 -0
- data/spec/site_inspector_cache_spec.rb +2 -0
- data/spec/site_inspector_disk_cache_spec.rb +8 -6
- data/spec/site_inspector_domain_spec.rb +34 -34
- data/spec/site_inspector_endpoint_spec.rb +44 -43
- data/spec/site_inspector_spec.rb +15 -13
- data/spec/spec_helper.rb +2 -0
- metadata +125 -55
@@ -1,26 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::DiskCache do
|
4
|
-
subject {
|
6
|
+
subject { described_class.new(tmpdir) }
|
5
7
|
|
6
8
|
before do
|
7
9
|
FileUtils.rm_rf(tmpdir)
|
8
10
|
Dir.mkdir(tmpdir)
|
9
11
|
end
|
10
12
|
|
11
|
-
it '
|
13
|
+
it 'writes a value to disk' do
|
12
14
|
foo = Typhoeus::Request.new('foo')
|
13
15
|
|
14
16
|
path = File.expand_path foo.cache_key, tmpdir
|
15
|
-
expect(File.exist?(path)).to
|
17
|
+
expect(File.exist?(path)).to be(false)
|
16
18
|
|
17
19
|
subject.set foo, 'bar'
|
18
20
|
|
19
|
-
expect(File.exist?(path)).to
|
21
|
+
expect(File.exist?(path)).to be(true)
|
20
22
|
expect(File.open(path).read).to eql("I\"bar:ET")
|
21
23
|
end
|
22
24
|
|
23
|
-
it '
|
25
|
+
it 'reads a value from disk' do
|
24
26
|
foo = Typhoeus::Request.new('foo')
|
25
27
|
|
26
28
|
path = File.expand_path foo.cache_key, tmpdir
|
@@ -28,7 +30,7 @@ describe SiteInspector::DiskCache do
|
|
28
30
|
expect(subject.get(foo)).to eql('bar')
|
29
31
|
end
|
30
32
|
|
31
|
-
it "
|
33
|
+
it "calculates a file's path" do
|
32
34
|
foo = Typhoeus::Request.new('foo')
|
33
35
|
|
34
36
|
path = File.expand_path foo.cache_key, tmpdir
|
@@ -1,41 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::Domain do
|
4
|
-
subject {
|
6
|
+
subject { described_class.new('example.com') }
|
5
7
|
|
6
8
|
context 'domain parsing' do
|
7
9
|
it 'downcases the domain' do
|
8
|
-
domain =
|
10
|
+
domain = described_class.new('EXAMPLE.com')
|
9
11
|
expect(domain.host).to eql('example.com')
|
10
12
|
end
|
11
13
|
|
12
14
|
it 'strips http from the domain' do
|
13
|
-
domain =
|
15
|
+
domain = described_class.new('http://example.com')
|
14
16
|
expect(domain.host).to eql('example.com')
|
15
17
|
end
|
16
18
|
|
17
19
|
it 'strips https from the domain' do
|
18
|
-
domain =
|
20
|
+
domain = described_class.new('https://example.com')
|
19
21
|
expect(domain.host).to eql('example.com')
|
20
22
|
end
|
21
23
|
|
22
24
|
it 'strips www from the domain' do
|
23
|
-
domain =
|
25
|
+
domain = described_class.new('www.example.com')
|
24
26
|
expect(domain.host).to eql('example.com')
|
25
27
|
end
|
26
28
|
|
27
29
|
it 'strips http://www from the domain' do
|
28
|
-
domain =
|
30
|
+
domain = described_class.new('http://www.example.com')
|
29
31
|
expect(domain.host).to eql('example.com')
|
30
32
|
end
|
31
33
|
|
32
34
|
it 'strips paths from the domain' do
|
33
|
-
domain =
|
35
|
+
domain = described_class.new('http://www.example.com/foo')
|
34
36
|
expect(domain.host).to eql('example.com')
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'strips trailing slashes from the domain' do
|
38
|
-
domain =
|
40
|
+
domain = described_class.new('http://www.example.com/')
|
39
41
|
expect(domain.host).to eql('example.com')
|
40
42
|
end
|
41
43
|
end
|
@@ -43,7 +45,7 @@ describe SiteInspector::Domain do
|
|
43
45
|
context 'endpoints' do
|
44
46
|
it 'generates the endpoints' do
|
45
47
|
endpoints = subject.endpoints
|
46
|
-
expect(endpoints.count).to
|
48
|
+
expect(endpoints.count).to be(4)
|
47
49
|
expect(endpoints[0].to_s).to eql('https://example.com/')
|
48
50
|
expect(endpoints[1].to_s).to eql('https://www.example.com/')
|
49
51
|
expect(endpoints[2].to_s).to eql('http://example.com/')
|
@@ -60,23 +62,21 @@ describe SiteInspector::Domain do
|
|
60
62
|
end
|
61
63
|
|
62
64
|
it 'knows if a domain is a government domain' do
|
63
|
-
expect(subject.government?).to
|
65
|
+
expect(subject.government?).to be(false)
|
64
66
|
|
65
|
-
domain =
|
66
|
-
expect(domain.government?).to
|
67
|
+
domain = described_class.new('whitehouse.gov')
|
68
|
+
expect(domain.government?).to be(true)
|
67
69
|
end
|
68
70
|
|
69
71
|
context 'up' do
|
70
72
|
it 'considers a domain up if at least one endpoint is up' do
|
71
73
|
subject.endpoints.each do |endpoint|
|
72
|
-
unless endpoint.uri.to_s.start_with?('http://www')
|
73
|
-
allow(endpoint).to receive(:response) { Typhoeus::Response.new(code: 0) }
|
74
|
-
end
|
74
|
+
allow(endpoint).to receive(:response) { Typhoeus::Response.new(code: 0) } unless endpoint.uri.to_s.start_with?('http://www')
|
75
75
|
end
|
76
76
|
|
77
77
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
78
78
|
|
79
|
-
expect(subject.up?).to
|
79
|
+
expect(subject.up?).to be(true)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "doesn't consider a domain up when all endpoints are down" do
|
@@ -84,7 +84,7 @@ describe SiteInspector::Domain do
|
|
84
84
|
allow(endpoint).to receive(:response) { Typhoeus::Response.new(code: 0) }
|
85
85
|
end
|
86
86
|
|
87
|
-
expect(subject.up?).to
|
87
|
+
expect(subject.up?).to be(false)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -95,7 +95,7 @@ describe SiteInspector::Domain do
|
|
95
95
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
96
96
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
97
97
|
|
98
|
-
expect(subject.up?).to
|
98
|
+
expect(subject.up?).to be(true)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "doesn't consider a domain up if all endpoints are down" do
|
@@ -104,7 +104,7 @@ describe SiteInspector::Domain do
|
|
104
104
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
105
105
|
stub_request(:head, 'http://www.example.com/').to_return(status: 500)
|
106
106
|
|
107
|
-
expect(subject.up?).to
|
107
|
+
expect(subject.up?).to be(false)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -115,7 +115,7 @@ describe SiteInspector::Domain do
|
|
115
115
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
116
116
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
117
117
|
|
118
|
-
expect(subject.www?).to
|
118
|
+
expect(subject.www?).to be(true)
|
119
119
|
end
|
120
120
|
|
121
121
|
it "doesn't consider a site www when no endpoint is www" do
|
@@ -124,7 +124,7 @@ describe SiteInspector::Domain do
|
|
124
124
|
stub_request(:head, 'http://example.com/').to_return(status: 200)
|
125
125
|
stub_request(:head, 'http://www.example.com/').to_return(status: 500)
|
126
126
|
|
127
|
-
expect(subject.www?).to
|
127
|
+
expect(subject.www?).to be(false)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -135,7 +135,7 @@ describe SiteInspector::Domain do
|
|
135
135
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
136
136
|
stub_request(:head, 'http://www.example.com/').to_return(status: 500)
|
137
137
|
|
138
|
-
expect(subject.root?).to
|
138
|
+
expect(subject.root?).to be(true)
|
139
139
|
end
|
140
140
|
|
141
141
|
it "doesn't call a www-only domain root" do
|
@@ -144,7 +144,7 @@ describe SiteInspector::Domain do
|
|
144
144
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
145
145
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
146
146
|
|
147
|
-
expect(subject.root?).to
|
147
|
+
expect(subject.root?).to be(false)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -154,9 +154,9 @@ describe SiteInspector::Domain do
|
|
154
154
|
stub_request(:head, 'https://www.example.com/').to_return(status: 200)
|
155
155
|
stub_request(:head, 'http://example.com/').to_return(status: 200)
|
156
156
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
157
|
-
allow(subject.endpoints.first.https).to receive(:valid?)
|
157
|
+
allow(subject.endpoints.first.https).to receive(:valid?).and_return(true)
|
158
158
|
|
159
|
-
expect(subject.https?).to
|
159
|
+
expect(subject.https?).to be(true)
|
160
160
|
end
|
161
161
|
|
162
162
|
it "knows when a domain doesn't support https" do
|
@@ -165,7 +165,7 @@ describe SiteInspector::Domain do
|
|
165
165
|
stub_request(:head, 'http://example.com/').to_return(status: 200)
|
166
166
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
167
167
|
|
168
|
-
expect(subject.https?).to
|
168
|
+
expect(subject.https?).to be(false)
|
169
169
|
end
|
170
170
|
|
171
171
|
it 'considers HTTPS inforced when no http endpoint responds' do
|
@@ -183,7 +183,7 @@ describe SiteInspector::Domain do
|
|
183
183
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
184
184
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
185
185
|
|
186
|
-
expect(subject.enforces_https?).to
|
186
|
+
expect(subject.enforces_https?).to be(false)
|
187
187
|
end
|
188
188
|
|
189
189
|
it 'detects when a domain downgrades to http' do
|
@@ -203,7 +203,7 @@ describe SiteInspector::Domain do
|
|
203
203
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
204
204
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
205
205
|
|
206
|
-
expect(subject.canonically_www?).to
|
206
|
+
expect(subject.canonically_www?).to be(true)
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'detects a domain as canonically www when root redirects' do
|
@@ -213,7 +213,7 @@ describe SiteInspector::Domain do
|
|
213
213
|
.to_return(status: 301, headers: { location: 'http://www.example.com' })
|
214
214
|
stub_request(:head, 'http://www.example.com/').to_return(status: 200)
|
215
215
|
|
216
|
-
expect(subject.canonically_www?).to
|
216
|
+
expect(subject.canonically_www?).to be(true)
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
@@ -223,9 +223,9 @@ describe SiteInspector::Domain do
|
|
223
223
|
stub_request(:head, 'https://www.example.com/').to_return(status: 200)
|
224
224
|
stub_request(:head, 'http://example.com/').to_return(status: 500)
|
225
225
|
stub_request(:head, 'http://www.example.com/').to_return(status: 500)
|
226
|
-
allow(subject.endpoints.first.https).to receive(:valid?)
|
226
|
+
allow(subject.endpoints.first.https).to receive(:valid?).and_return(true)
|
227
227
|
|
228
|
-
expect(subject.canonically_https?).to
|
228
|
+
expect(subject.canonically_https?).to be(true)
|
229
229
|
end
|
230
230
|
|
231
231
|
it 'detects a domain as canonically https when http redirect' do
|
@@ -234,9 +234,9 @@ describe SiteInspector::Domain do
|
|
234
234
|
stub_request(:head, 'http://example.com/')
|
235
235
|
.to_return(status: 301, headers: { location: 'https://example.com' })
|
236
236
|
stub_request(:head, 'http://www.example.com/').to_return(status: 500)
|
237
|
-
allow(subject.endpoints.first.https).to receive(:valid?)
|
237
|
+
allow(subject.endpoints.first.https).to receive(:valid?).and_return(true)
|
238
238
|
|
239
|
-
expect(subject.canonically_https?).to
|
239
|
+
expect(subject.canonically_https?).to be(true)
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
@@ -250,7 +250,7 @@ describe SiteInspector::Domain do
|
|
250
250
|
stub_request(:head, 'http://www.example.com/').to_return(status: 500)
|
251
251
|
stub_request(:head, 'http://foo.example.com/').to_return(status: 200)
|
252
252
|
|
253
|
-
expect(subject.redirect?).to
|
253
|
+
expect(subject.redirect?).to be(true)
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
@@ -1,16 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SiteInspector::Endpoint do
|
4
|
-
|
5
|
-
subject { SiteInspector::Endpoint.new('http://example.com') }
|
6
|
+
subject { described_class.new('http://example.com') }
|
6
7
|
|
7
8
|
it 'downcases the host' do
|
8
|
-
endpoint =
|
9
|
+
endpoint = described_class.new('http://EXAMPLE.com')
|
9
10
|
expect(endpoint.host).to eql('example.com')
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'strips www from the host' do
|
13
|
-
endpoint =
|
14
|
+
endpoint = described_class.new('http://www.example.com')
|
14
15
|
expect(endpoint.host).to eql('example.com')
|
15
16
|
end
|
16
17
|
|
@@ -19,12 +20,12 @@ describe SiteInspector::Endpoint do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'knows if an endpoint is www' do
|
22
|
-
expect(subject.www?).to
|
23
|
-
expect(subject.root?).to
|
23
|
+
expect(subject.www?).to be(false)
|
24
|
+
expect(subject.root?).to be(true)
|
24
25
|
|
25
|
-
endpoint =
|
26
|
-
expect(endpoint.www?).to
|
27
|
-
expect(endpoint.root?).to
|
26
|
+
endpoint = described_class.new('http://www.example.com')
|
27
|
+
expect(endpoint.www?).to be(true)
|
28
|
+
expect(endpoint.root?).to be(false)
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'knows if an endpoint is http' do
|
@@ -34,8 +35,8 @@ describe SiteInspector::Endpoint do
|
|
34
35
|
stub_request(:head, 'https://example.com/')
|
35
36
|
.to_return(status: 500, body: 'content')
|
36
37
|
|
37
|
-
expect(subject.https?).to
|
38
|
-
expect(subject.http?).to
|
38
|
+
expect(subject.https?).to be(false)
|
39
|
+
expect(subject.http?).to be(true)
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'knows if an endpoint is https' do
|
@@ -45,15 +46,15 @@ describe SiteInspector::Endpoint do
|
|
45
46
|
stub_request(:head, 'https://example.com/')
|
46
47
|
.to_return(status: 200, body: 'content')
|
47
48
|
|
48
|
-
endpoint =
|
49
|
-
expect(endpoint.https?).to
|
50
|
-
expect(endpoint.http?).to
|
49
|
+
endpoint = described_class.new('https://example.com')
|
50
|
+
expect(endpoint.https?).to be(true)
|
51
|
+
expect(endpoint.http?).to be(false)
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'knows the scheme' do
|
54
55
|
expect(subject.scheme).to eql('http')
|
55
56
|
|
56
|
-
endpoint =
|
57
|
+
endpoint = described_class.new('https://example.com')
|
57
58
|
expect(endpoint.scheme).to eql('https')
|
58
59
|
end
|
59
60
|
|
@@ -79,7 +80,7 @@ describe SiteInspector::Endpoint do
|
|
79
80
|
.to_return(status: 301, headers: { location: 'http://example.com/foo' })
|
80
81
|
|
81
82
|
response = subject.request(followlocation: true)
|
82
|
-
expect(response.request.options[:followlocation]).to
|
83
|
+
expect(response.request.options[:followlocation]).to be(true)
|
83
84
|
end
|
84
85
|
|
85
86
|
it 'returns the response' do
|
@@ -95,15 +96,15 @@ describe SiteInspector::Endpoint do
|
|
95
96
|
stub_request(:head, 'http://example.com/')
|
96
97
|
.to_return(status: 200, body: 'content')
|
97
98
|
|
98
|
-
expect(subject.responds?).to
|
99
|
+
expect(subject.responds?).to be(true)
|
99
100
|
end
|
100
101
|
|
101
102
|
it "knows when there's not a response" do
|
102
103
|
allow(subject).to receive(:response) { Typhoeus::Response.new(code: 0) }
|
103
|
-
expect(subject.responds?).to
|
104
|
+
expect(subject.responds?).to be(false)
|
104
105
|
|
105
106
|
allow(subject).to receive(:response) { Typhoeus::Response.new(return_code: :operation_timedout) }
|
106
|
-
expect(subject.responds?).to
|
107
|
+
expect(subject.responds?).to be(false)
|
107
108
|
end
|
108
109
|
|
109
110
|
it 'knows the response code' do
|
@@ -115,53 +116,53 @@ describe SiteInspector::Endpoint do
|
|
115
116
|
|
116
117
|
it 'knows if a response has timed out' do
|
117
118
|
allow(subject).to receive(:response) { Typhoeus::Response.new(return_code: :operation_timedout) }
|
118
|
-
expect(subject.timed_out?).to
|
119
|
+
expect(subject.timed_out?).to be(true)
|
119
120
|
end
|
120
121
|
|
121
122
|
it 'considers a 200 response code to be live and a response' do
|
122
123
|
stub_request(:head, 'http://example.com/')
|
123
124
|
.to_return(status: 200)
|
124
125
|
|
125
|
-
expect(subject.up?).to
|
126
|
-
expect(subject.responds?).to
|
126
|
+
expect(subject.up?).to be(true)
|
127
|
+
expect(subject.responds?).to be(true)
|
127
128
|
end
|
128
129
|
|
129
130
|
it 'considers a 301 response code to be live and a response' do
|
130
131
|
stub_request(:head, 'http://example.com/')
|
131
132
|
.to_return(status: 301)
|
132
133
|
|
133
|
-
expect(subject.up?).to
|
134
|
-
expect(subject.responds?).to
|
134
|
+
expect(subject.up?).to be(true)
|
135
|
+
expect(subject.responds?).to be(true)
|
135
136
|
end
|
136
137
|
|
137
138
|
it 'considers a 404 response code to be down but a response' do
|
138
139
|
stub_request(:head, 'http://example.com/')
|
139
140
|
.to_return(status: 404)
|
140
141
|
|
141
|
-
expect(subject.up?).to
|
142
|
-
expect(subject.responds?).to
|
142
|
+
expect(subject.up?).to be(false)
|
143
|
+
expect(subject.responds?).to be(true)
|
143
144
|
end
|
144
145
|
|
145
146
|
it 'considers a 500 response code to be down but a response' do
|
146
147
|
stub_request(:head, 'http://example.com/')
|
147
148
|
.to_return(status: 500)
|
148
149
|
|
149
|
-
expect(subject.up?).to
|
150
|
-
expect(subject.responds?).to
|
150
|
+
expect(subject.up?).to be(false)
|
151
|
+
expect(subject.responds?).to be(true)
|
151
152
|
end
|
152
153
|
|
153
154
|
it 'considers a 0 response code (error) to down and unresponsive' do
|
154
155
|
allow(subject).to receive(:response) { Typhoeus::Response.new(code: 0) }
|
155
156
|
|
156
|
-
expect(subject.up?).to
|
157
|
-
expect(subject.responds?).to
|
157
|
+
expect(subject.up?).to be(false)
|
158
|
+
expect(subject.responds?).to be(false)
|
158
159
|
end
|
159
160
|
|
160
161
|
it 'considers a timeout to be down and unresponsive' do
|
161
162
|
allow(subject).to receive(:response) { Typhoeus::Response.new(return_code: :operation_timedout) }
|
162
163
|
|
163
|
-
expect(subject.up?).to
|
164
|
-
expect(subject.responds?).to
|
164
|
+
expect(subject.up?).to be(false)
|
165
|
+
expect(subject.responds?).to be(false)
|
165
166
|
end
|
166
167
|
end
|
167
168
|
|
@@ -170,7 +171,7 @@ describe SiteInspector::Endpoint do
|
|
170
171
|
stub_request(:head, 'http://example.com/')
|
171
172
|
.to_return(status: 301, headers: { location: 'http://www.example.com' })
|
172
173
|
|
173
|
-
expect(subject.redirect?).to
|
174
|
+
expect(subject.redirect?).to be(true)
|
174
175
|
end
|
175
176
|
|
176
177
|
it 'returns the redirect' do
|
@@ -187,14 +188,14 @@ describe SiteInspector::Endpoint do
|
|
187
188
|
stub_request(:head, 'http://example.com/')
|
188
189
|
.to_return(status: 301, headers: { location: '/foo' })
|
189
190
|
|
190
|
-
expect(subject.redirect?).to
|
191
|
+
expect(subject.redirect?).to be(false)
|
191
192
|
end
|
192
193
|
|
193
194
|
it 'handles relative redirects without a leading slash' do
|
194
195
|
stub_request(:head, 'http://example.com/')
|
195
196
|
.to_return(status: 301, headers: { location: 'foo' })
|
196
197
|
|
197
|
-
expect(subject.redirect?).to
|
198
|
+
expect(subject.redirect?).to be(false)
|
198
199
|
end
|
199
200
|
|
200
201
|
it 'knows what it resolves to' do
|
@@ -204,7 +205,7 @@ describe SiteInspector::Endpoint do
|
|
204
205
|
stub_request(:head, 'http://www.example.com/')
|
205
206
|
.to_return(status: 200)
|
206
207
|
|
207
|
-
expect(subject.redirect?).to
|
208
|
+
expect(subject.redirect?).to be(true)
|
208
209
|
expect(subject.resolves_to.uri.to_s).to eql('http://www.example.com/')
|
209
210
|
end
|
210
211
|
|
@@ -215,8 +216,8 @@ describe SiteInspector::Endpoint do
|
|
215
216
|
stub_request(:head, 'http://www.example.gov')
|
216
217
|
.to_return(status: 200)
|
217
218
|
|
218
|
-
expect(subject.redirect?).to
|
219
|
-
expect(subject.external_redirect?).to
|
219
|
+
expect(subject.redirect?).to be(true)
|
220
|
+
expect(subject.external_redirect?).to be(true)
|
220
221
|
end
|
221
222
|
|
222
223
|
it 'knows internal redirects are not external redirects' do
|
@@ -226,24 +227,24 @@ describe SiteInspector::Endpoint do
|
|
226
227
|
stub_request(:head, 'https://example.com/')
|
227
228
|
.to_return(status: 200)
|
228
229
|
|
229
|
-
expect(subject.external_redirect?).to
|
230
|
+
expect(subject.external_redirect?).to be(false)
|
230
231
|
end
|
231
232
|
end
|
232
233
|
|
233
234
|
context 'checks' do
|
234
235
|
it 'identifies checks' do
|
235
|
-
expected =
|
236
|
+
expected = 9
|
236
237
|
pa11y = SiteInspector::Endpoint::Accessibility.pa11y?
|
237
238
|
expected -= 1 unless pa11y
|
238
|
-
expect(
|
239
|
+
expect(described_class.checks.count).to eql(expected)
|
239
240
|
end
|
240
241
|
|
241
|
-
|
242
|
+
described_class.checks.each do |check|
|
242
243
|
it "responds to the #{check} check" do
|
243
244
|
stub_request(:head, 'http://example.com/')
|
244
245
|
.to_return(status: 200)
|
245
246
|
|
246
|
-
expect(subject.send(check.name)).
|
247
|
+
expect(subject.send(check.name)).not_to be_nil
|
247
248
|
expect(subject.send(check.name).class).to eql(check)
|
248
249
|
end
|
249
250
|
end
|