ndd-url_checker 0.3.2 → 0.3.3
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/CHANGELOG.md +8 -0
- data/LICENSE.txt +18 -17
- data/README.md +14 -7
- data/lib/ndd/url_checker.rb +6 -0
- data/lib/ndd/url_checker/reporting_url_checker.rb +4 -0
- data/lib/ndd/url_checker/status.rb +1 -0
- data/lib/ndd/url_checker/status_decorator.rb +11 -0
- data/lib/ndd/url_checker/version.rb +5 -0
- metadata +9 -249
- data/.document +0 -5
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -16
- data/Gemfile +0 -50
- data/Gemfile.lock +0 -162
- data/Guardfile +0 -38
- data/Rakefile +0 -51
- data/VERSION +0 -1
- data/lib/ndd/url_checker/reporting_url_checker.csv.erb +0 -4
- data/lib/ndd/url_checker/reporting_url_checker.html.erb +0 -188
- data/lib/ndd/url_checker/reporting_url_checker.json.erb +0 -27
- data/ndd-url_checker.gemspec +0 -134
- data/spec/ndd/url_checker/abstract_url_checker_spec.rb +0 -11
- data/spec/ndd/url_checker/blocking_url_checker_spec.rb +0 -12
- data/spec/ndd/url_checker/forked_url_checker_spec.rb +0 -12
- data/spec/ndd/url_checker/parallel_url_checker_spec.rb +0 -62
- data/spec/ndd/url_checker/reporting_url_checker/custom.txt.erb +0 -8
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.csv +0 -6
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.html +0 -246
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.json +0 -49
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.txt +0 -26
- data/spec/ndd/url_checker/reporting_url_checker/single_url.csv +0 -2
- data/spec/ndd/url_checker/reporting_url_checker/single_url.html +0 -182
- data/spec/ndd/url_checker/reporting_url_checker/single_url.json +0 -25
- data/spec/ndd/url_checker/reporting_url_checker/single_url.txt +0 -6
- data/spec/ndd/url_checker/reporting_url_checker_spec.rb +0 -131
- data/spec/ndd/url_checker/status_decorator_spec.rb +0 -208
- data/spec/ndd/url_checker/status_spec.rb +0 -510
- data/spec/ndd/url_checker/threaded_url_checker_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -81
- data/spec/support/multiple_url_checker_spec.rb +0 -58
- data/spec/support/single_url_checker_spec.rb +0 -252
@@ -1,510 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe NDD::UrlChecker::Status do
|
4
|
-
|
5
|
-
# ------------------------------------------------------------------------------------------------------ unknown -----
|
6
|
-
context 'when initialized' do
|
7
|
-
let(:uri) { 'http://www.example.com' }
|
8
|
-
let(:status) { NDD::UrlChecker::Status.new(uri) }
|
9
|
-
|
10
|
-
context '#uri' do
|
11
|
-
it 'returns the original URI' do
|
12
|
-
expect(status.uri).to eq uri
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context '#uris' do
|
17
|
-
it 'returns the original URI' do
|
18
|
-
expect(status.uris).to eq [uri]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context '#code' do
|
23
|
-
it 'returns :unknown' do
|
24
|
-
expect(status.code).to eq :unknown
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context '#valid?' do
|
29
|
-
it 'returns false' do
|
30
|
-
expect(status.valid?).to be_falsey
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context '#invalid?' do
|
35
|
-
it 'returns false' do
|
36
|
-
expect(status.invalid?).to be_falsey
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context '#error' do
|
41
|
-
it 'returns nil' do
|
42
|
-
expect(status.error).to be_nil
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context '#direct' do
|
47
|
-
let!(:new_status) { status.direct }
|
48
|
-
it 'changes the code to :direct' do
|
49
|
-
expect(status.code).to eq :direct
|
50
|
-
end
|
51
|
-
it 'returns the status' do
|
52
|
-
expect(new_status).to eq status
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context '#failed' do
|
57
|
-
let!(:new_status) { status.failed(StandardError.new('some error')) }
|
58
|
-
it 'changes the code to :failed' do
|
59
|
-
expect(status.code).to eq :failed
|
60
|
-
end
|
61
|
-
it 'returns the status' do
|
62
|
-
expect(new_status).to eq status
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context '#redirected' do
|
67
|
-
let!(:new_status) { status.redirected('http://www.redirected.com') }
|
68
|
-
it 'changes the code to :redirected' do
|
69
|
-
expect(status.code).to eq :redirected
|
70
|
-
end
|
71
|
-
it 'returns the status' do
|
72
|
-
expect(new_status).to eq status
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context '#too_many_redirects' do
|
77
|
-
let!(:new_status) { status.too_many_redirects }
|
78
|
-
it 'changes the code to :too_many_redirects' do
|
79
|
-
expect(status.code).to eq :too_many_redirects
|
80
|
-
end
|
81
|
-
it 'returns the status' do
|
82
|
-
expect(new_status).to eq status
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context '#unknown_host' do
|
87
|
-
it 'changes the code to :unknown_host' do
|
88
|
-
status.unknown_host
|
89
|
-
expect(status.code).to eq :unknown_host
|
90
|
-
end
|
91
|
-
it 'returns the status' do
|
92
|
-
expect(status.unknown_host).to eq status
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context '#to_s' do
|
97
|
-
it 'returns the status representation' do
|
98
|
-
expect(status.to_s).to match %r{^#<NDD::UrlChecker::Status:0[xX][0-9a-fA-F]+ @uris=\["http://www.example.com"\], @code=:unknown>$}
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# ------------------------------------------------------------------------------------------------------- direct -----
|
104
|
-
context 'when code is :direct' do
|
105
|
-
let(:uri) { 'http://www.example.com' }
|
106
|
-
let(:status) { NDD::UrlChecker::Status.new(uri).direct }
|
107
|
-
|
108
|
-
context '#uri' do
|
109
|
-
it 'returns the original URI' do
|
110
|
-
expect(status.uri).to eq uri
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
context '#uris' do
|
115
|
-
it 'returns the original URI' do
|
116
|
-
expect(status.uris).to eq [uri]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context '#code' do
|
121
|
-
it 'returns :direct' do
|
122
|
-
expect(status.code).to eq :direct
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context '#valid?' do
|
127
|
-
it 'returns true' do
|
128
|
-
expect(status.valid?).to be_truthy
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context '#invalid?' do
|
133
|
-
it 'returns false' do
|
134
|
-
expect(status.invalid?).to be_falsey
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context '#error' do
|
139
|
-
it 'returns nil' do
|
140
|
-
expect(status.error).to be_nil
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
context '#direct' do
|
145
|
-
it 'raises an error' do
|
146
|
-
expect { status.direct }.to raise_error(/from :direct to :direct is forbidden/)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context '#failed' do
|
151
|
-
it 'raises an error' do
|
152
|
-
expect { status.failed(StandardError.new('some error')) }.to raise_error(/from :direct to :failed is forbidden/)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context '#redirected' do
|
157
|
-
it 'raises an error' do
|
158
|
-
expect { status.redirected('http://www.redirected.com') }.to raise_error(/from :direct to :redirected is forbidden/)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context '#too_many_redirects' do
|
163
|
-
it 'raises an error' do
|
164
|
-
expect { status.too_many_redirects }.to raise_error(/from :direct to :too_many_redirects is forbidden/)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context '#unknown_host' do
|
169
|
-
it 'raises an error' do
|
170
|
-
expect { status.unknown_host }.to raise_error(/from :direct to :unknown_host is forbidden/)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
context '#to_s' do
|
175
|
-
it 'returns the status representation' do
|
176
|
-
expect(status.to_s).to match %r{^#<NDD::UrlChecker::Status:0[xX][0-9a-fA-F]+ @uris=\["http://www.example.com"\], @code=:direct>$}
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
# ------------------------------------------------------------------------------------------------------- failed -----
|
182
|
-
context 'when code is :failed' do
|
183
|
-
let(:uri) { 'http://www.example.com' }
|
184
|
-
let(:status) { NDD::UrlChecker::Status.new(uri).failed(StandardError.new('some error')) }
|
185
|
-
|
186
|
-
context '#uri' do
|
187
|
-
it 'returns the original URI' do
|
188
|
-
expect(status.uri).to eq uri
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context '#uris' do
|
193
|
-
it 'returns the original URI' do
|
194
|
-
expect(status.uris).to eq [uri]
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context '#code' do
|
199
|
-
it 'returns :failed' do
|
200
|
-
expect(status.code).to eq :failed
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
context '#valid?' do
|
205
|
-
it 'returns false' do
|
206
|
-
expect(status.valid?).to be_falsey
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context '#invalid?' do
|
211
|
-
it 'returns true' do
|
212
|
-
expect(status.invalid?).to be_truthy
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context '#error' do
|
217
|
-
it 'returns the error' do
|
218
|
-
expect(status.error).to eq StandardError.new('some error')
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
context '#direct' do
|
223
|
-
it 'raises an error' do
|
224
|
-
expect { status.direct }.to raise_error(/from :failed to :direct is forbidden/)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context '#failed' do
|
229
|
-
it 'raises an error' do
|
230
|
-
expect { status.failed(StandardError.new('some error')) }.to raise_error(/from :failed to :failed is forbidden/)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
context '#redirected' do
|
235
|
-
it 'raises an error' do
|
236
|
-
expect { status.redirected('http://www.redirected.com') }.to raise_error(/from :failed to :redirected is forbidden/)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
context '#too_many_redirects' do
|
241
|
-
it 'raises an error' do
|
242
|
-
expect { status.too_many_redirects }.to raise_error(/from :failed to :too_many_redirects is forbidden/)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
context '#unknown_host' do
|
247
|
-
it 'raises an error' do
|
248
|
-
expect { status.unknown_host }.to raise_error(/from :failed to :unknown_host is forbidden/)
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
context '#to_s' do
|
253
|
-
it 'returns the status representation' do
|
254
|
-
expect(status.to_s).to match %r{^#<NDD::UrlChecker::Status:0[xX][0-9a-fA-F]+ @uris=\["http://www.example.com"\], @code=:failed, @error=#<StandardError: some error>>$}
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# --------------------------------------------------------------------------------------------------- redirected -----
|
260
|
-
context 'when code is :redirected' do
|
261
|
-
let(:uri) { 'http://www.example.com' }
|
262
|
-
let(:redirect_uri) { 'http://www.redirected.com' }
|
263
|
-
let(:status) { NDD::UrlChecker::Status.new(uri).redirected(redirect_uri) }
|
264
|
-
|
265
|
-
context '#uri' do
|
266
|
-
it 'returns the original URI' do
|
267
|
-
expect(status.uri).to eq uri
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
context '#uris' do
|
272
|
-
it 'returns all the URI' do
|
273
|
-
expect(status.uris).to eq [uri, redirect_uri]
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
context '#code' do
|
278
|
-
it 'returns :redirected' do
|
279
|
-
expect(status.code).to eq :redirected
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
context '#valid?' do
|
284
|
-
it 'returns true' do
|
285
|
-
expect(status.valid?).to be_truthy
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
context '#invalid?' do
|
290
|
-
it 'returns false' do
|
291
|
-
expect(status.invalid?).to be_falsey
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
context '#error' do
|
296
|
-
it 'returns nil' do
|
297
|
-
expect(status.error).to be_nil
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
context '#direct' do
|
302
|
-
it 'raises an error' do
|
303
|
-
expect { status.direct }.to raise_error(/from :redirected to :direct is forbidden/)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
context '#failed' do
|
308
|
-
let!(:new_status) { status.failed(StandardError.new('some error')) }
|
309
|
-
it 'changes the code to :failed' do
|
310
|
-
expect(status.code).to eq :failed
|
311
|
-
end
|
312
|
-
it 'returns the status' do
|
313
|
-
expect(new_status).to eq status
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
context '#redirected' do
|
318
|
-
let!(:new_status) { status.redirected('http://www.redirected.com') }
|
319
|
-
it 'changes the code to :redirected' do
|
320
|
-
expect(status.code).to eq :redirected
|
321
|
-
end
|
322
|
-
it 'returns the status' do
|
323
|
-
expect(new_status).to eq status
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
context '#too_many_redirects' do
|
328
|
-
let!(:new_status) { status.too_many_redirects }
|
329
|
-
it 'changes the code to :too_many_redirects' do
|
330
|
-
expect(status.code).to eq :too_many_redirects
|
331
|
-
end
|
332
|
-
it 'returns the status' do
|
333
|
-
expect(new_status).to eq status
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
context '#unknown_host' do
|
338
|
-
it 'changes the code to :unknown_host' do
|
339
|
-
status.unknown_host
|
340
|
-
expect(status.code).to eq :unknown_host
|
341
|
-
end
|
342
|
-
it 'returns the status' do
|
343
|
-
expect(status.unknown_host).to eq status
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
context '#to_s' do
|
348
|
-
it 'returns the status representation' do
|
349
|
-
expect(status.to_s).to match %r{^#<NDD::UrlChecker::Status:0[xX][0-9a-fA-F]+ @uris=\["http://www.example.com", "http://www.redirected.com"\], @code=:redirected>$}
|
350
|
-
end
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
# ------------------------------------------------------------------------------------------- too_many_redirects -----
|
355
|
-
context 'when code is :too_many_redirects' do
|
356
|
-
let(:uri) { 'http://www.example.com' }
|
357
|
-
let(:status) { NDD::UrlChecker::Status.new(uri).too_many_redirects }
|
358
|
-
|
359
|
-
context '#uri' do
|
360
|
-
it 'returns the original URI' do
|
361
|
-
expect(status.uri).to eq uri
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
context '#uris' do
|
366
|
-
it 'returns the original URI' do
|
367
|
-
expect(status.uris).to eq [uri]
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
context '#code' do
|
372
|
-
it 'returns :too_many_redirects' do
|
373
|
-
expect(status.code).to eq :too_many_redirects
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
context '#valid?' do
|
378
|
-
it 'returns false' do
|
379
|
-
expect(status.valid?).to be_falsey
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
context '#invalid?' do
|
384
|
-
it 'returns true' do
|
385
|
-
expect(status.invalid?).to be_truthy
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
context '#error' do
|
390
|
-
it 'returns nil' do
|
391
|
-
expect(status.error).to be_nil
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
context '#direct' do
|
396
|
-
it 'raises an error' do
|
397
|
-
expect { status.direct }.to raise_error(/from :too_many_redirects to :direct is forbidden/)
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
context '#failed' do
|
402
|
-
it 'raises an error' do
|
403
|
-
expect { status.failed(StandardError.new('some error')) }.to raise_error(/from :too_many_redirects to :failed is forbidden/)
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
context '#redirected' do
|
408
|
-
it 'raises an error' do
|
409
|
-
expect { status.redirected('http://www.redirected.com') }.to raise_error(/from :too_many_redirects to :redirected is forbidden/)
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
context '#too_many_redirects' do
|
414
|
-
it 'raises an error' do
|
415
|
-
expect { status.too_many_redirects }.to raise_error(/from :too_many_redirects to :too_many_redirects is forbidden/)
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
context '#unknown_host' do
|
420
|
-
it 'raises an error' do
|
421
|
-
expect { status.unknown_host }.to raise_error(/from :too_many_redirects to :unknown_host is forbidden/)
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
context '#to_s' do
|
426
|
-
it 'returns the status representation' do
|
427
|
-
expect(status.to_s).to match %r{^#<NDD::UrlChecker::Status:0[xX][0-9a-fA-F]+ @uris=\["http://www.example.com"\], @code=:too_many_redirects>$}
|
428
|
-
end
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|
432
|
-
# ------------------------------------------------------------------------------------------------- unknown_host -----
|
433
|
-
context 'when code is :unknown_host' do
|
434
|
-
let(:uri) { 'http://www.example.com' }
|
435
|
-
let(:status) { NDD::UrlChecker::Status.new(uri).unknown_host }
|
436
|
-
|
437
|
-
context '#uri' do
|
438
|
-
it 'returns the original URI' do
|
439
|
-
expect(status.uri).to eq uri
|
440
|
-
end
|
441
|
-
end
|
442
|
-
|
443
|
-
context '#uris' do
|
444
|
-
it 'returns the original URI' do
|
445
|
-
expect(status.uris).to eq [uri]
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
context '#code' do
|
450
|
-
it 'returns :unknown_host' do
|
451
|
-
expect(status.code).to eq :unknown_host
|
452
|
-
end
|
453
|
-
end
|
454
|
-
|
455
|
-
context '#valid?' do
|
456
|
-
it 'returns false' do
|
457
|
-
expect(status.valid?).to be_falsey
|
458
|
-
end
|
459
|
-
end
|
460
|
-
|
461
|
-
context '#invalid?' do
|
462
|
-
it 'returns true' do
|
463
|
-
expect(status.invalid?).to be_truthy
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
context '#error' do
|
468
|
-
it 'returns nil' do
|
469
|
-
expect(status.error).to be_nil
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
context '#direct' do
|
474
|
-
it 'raises an error' do
|
475
|
-
expect { status.direct }.to raise_error(/from :unknown_host to :direct is forbidden/)
|
476
|
-
end
|
477
|
-
end
|
478
|
-
|
479
|
-
context '#failed' do
|
480
|
-
it 'raises an error' do
|
481
|
-
expect { status.failed(StandardError.new('some error')) }.to raise_error(/from :unknown_host to :failed is forbidden/)
|
482
|
-
end
|
483
|
-
end
|
484
|
-
|
485
|
-
context '#redirected' do
|
486
|
-
it 'raises an error' do
|
487
|
-
expect { status.redirected('http://www.redirected.com') }.to raise_error(/from :unknown_host to :redirected is forbidden/)
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
context '#too_many_redirects' do
|
492
|
-
it 'raises an error' do
|
493
|
-
expect { status.too_many_redirects }.to raise_error(/from :unknown_host to :too_many_redirects is forbidden/)
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
context '#unknown_host' do
|
498
|
-
it 'raises an error' do
|
499
|
-
expect { status.unknown_host }.to raise_error(/from :unknown_host to :unknown_host is forbidden/)
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
context '#to_s' do
|
504
|
-
it 'returns the status representation' do
|
505
|
-
expect(status.to_s).to match %r{^#<NDD::UrlChecker::Status:0[xX][0-9a-fA-F]+ @uris=\["http://www.example.com"\], @code=:unknown_host>$}
|
506
|
-
end
|
507
|
-
end
|
508
|
-
end
|
509
|
-
|
510
|
-
end
|