ruby-link-checker 0.4.0 → 0.6.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/CHANGELOG.md +34 -0
- data/LICENSE.md +0 -0
- data/README.md +227 -19
- data/UPGRADING.md +46 -0
- data/lib/ruby-link-checker/async/http/checker.rb +46 -7
- data/lib/ruby-link-checker/async/http/config.rb +4 -0
- data/lib/ruby-link-checker/async/http/result.rb +5 -1
- data/lib/ruby-link-checker/async/http.rb +0 -0
- data/lib/ruby-link-checker/cache.rb +170 -0
- data/lib/ruby-link-checker/callbacks.rb +0 -0
- data/lib/ruby-link-checker/checker.rb +200 -5
- data/lib/ruby-link-checker/config.rb +141 -0
- data/lib/ruby-link-checker/errors/base_error.rb +0 -0
- data/lib/ruby-link-checker/errors/connection_error.rb +23 -0
- data/lib/ruby-link-checker/errors/redirect_limit_error.rb +15 -0
- data/lib/ruby-link-checker/errors/redirect_loop_error.rb +0 -0
- data/lib/ruby-link-checker/errors.rb +2 -0
- data/lib/ruby-link-checker/logger.rb +0 -0
- data/lib/ruby-link-checker/net/http/checker.rb +5 -3
- data/lib/ruby-link-checker/net/http/config.rb +0 -0
- data/lib/ruby-link-checker/net/http/result.rb +5 -1
- data/lib/ruby-link-checker/net/http.rb +0 -0
- data/lib/ruby-link-checker/redirect.rb +11 -0
- data/lib/ruby-link-checker/result.rb +120 -0
- data/lib/ruby-link-checker/task.rb +2 -0
- data/lib/ruby-link-checker/tasks.rb +53 -7
- data/lib/ruby-link-checker/typhoeus/hydra/checker.rb +79 -9
- data/lib/ruby-link-checker/typhoeus/hydra/config.rb +0 -0
- data/lib/ruby-link-checker/typhoeus/hydra/result.rb +5 -1
- data/lib/ruby-link-checker/typhoeus/hydra.rb +0 -0
- data/lib/ruby-link-checker/version.rb +1 -1
- data/lib/ruby-link-checker.rb +2 -0
- data/lib/ruby_link_checker.rb +0 -0
- metadata +26 -72
- data/CONTRIBUTING.md +0 -125
- data/Dangerfile +0 -6
- data/Gemfile +0 -24
- data/Gemfile.lock +0 -334
- data/RELEASING.md +0 -60
- data/Rakefile +0 -18
- data/benchmarks/check.rb +0 -38
- data/benchmarks/data/opensearch.org/links.txt +0 -4270
- data/benchmarks/data/opensearch.org/small.txt +0 -100
- data/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_both.png +0 -0
- data/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/coverage/assets/0.13.2/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/coverage/assets/0.13.2/application.css +0 -1
- data/coverage/assets/0.13.2/application.js +0 -7
- data/coverage/assets/0.13.2/colorbox/border.png +0 -0
- data/coverage/assets/0.13.2/colorbox/controls.png +0 -0
- data/coverage/assets/0.13.2/colorbox/loading.gif +0 -0
- data/coverage/assets/0.13.2/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.13.2/favicon_green.png +0 -0
- data/coverage/assets/0.13.2/favicon_red.png +0 -0
- data/coverage/assets/0.13.2/favicon_yellow.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.13.2/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.13.2/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.13.2/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.13.2/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.13.2/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.13.2/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.13.2/loading.gif +0 -0
- data/coverage/assets/0.13.2/magnify.png +0 -0
- data/coverage/index.html +0 -10746
- data/ruby-link-checker.gemspec +0 -22
- data/spec/fixtures/200.yml +0 -65
- data/spec/fixtures/301_200.yml +0 -102
- data/spec/fixtures/301_301.yml +0 -114
- data/spec/fixtures/301_400_301_200.yml +0 -185
- data/spec/fixtures/301_403.yml +0 -78
- data/spec/fixtures/308_429.yml +0 -108
- data/spec/fixtures/404.yml +0 -57
- data/spec/fixtures/404_200.yml +0 -89
- data/spec/fixtures/404_404.yml +0 -81
- data/spec/fixtures/429_200.yml +0 -135
- data/spec/fixtures/429_429_200.yml +0 -201
- data/spec/ruby-link-checker/async/http/checker_spec.rb +0 -99
- data/spec/ruby-link-checker/callbacks_spec.rb +0 -76
- data/spec/ruby-link-checker/checker_spec.rb +0 -10
- data/spec/ruby-link-checker/config_spec.rb +0 -39
- data/spec/ruby-link-checker/errors/redirect_loop_error_spec.rb +0 -18
- data/spec/ruby-link-checker/net/http/checker_spec.rb +0 -78
- data/spec/ruby-link-checker/result_error_spec.rb +0 -17
- data/spec/ruby-link-checker/result_spec.rb +0 -41
- data/spec/ruby-link-checker/task_spec.rb +0 -20
- data/spec/ruby-link-checker/tasks_spec.rb +0 -47
- data/spec/ruby-link-checker/typhoeus/hydra/checker_spec.rb +0 -93
- data/spec/ruby-link-checker/version_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -19
- data/spec/support/config.rb +0 -8
- data/spec/support/link_checker.rb +0 -369
- data/spec/support/vcr.rb +0 -13
- data/spec/support/with_result.rb +0 -15
- data/spec/support/with_url.rb +0 -14
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
shared_context 'a link checker' do
|
|
2
|
-
context 'default' do
|
|
3
|
-
subject do
|
|
4
|
-
described_class.new
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
it 'has a default user-agent' do
|
|
8
|
-
expect(subject.user_agent).to eq "Ruby Link Checker/#{LinkChecker::VERSION}"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it 'has no default headers' do
|
|
12
|
-
expect(subject.headers).to eq({})
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'user-agent' do
|
|
17
|
-
subject do
|
|
18
|
-
described_class.new(user_agent: 'user/agent')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'updates user-agent' do
|
|
22
|
-
expect(subject.user_agent).to eq 'user/agent'
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'headers' do
|
|
27
|
-
subject do
|
|
28
|
-
described_class.new(headers: { 'DNT' => '1' })
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'updates headers' do
|
|
32
|
-
expect(subject.headers).to eq('DNT' => '1')
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context 'check' do
|
|
37
|
-
let(:url) { 'https://www.example.org' }
|
|
38
|
-
|
|
39
|
-
include_context 'with result'
|
|
40
|
-
|
|
41
|
-
context 'with metadata' do
|
|
42
|
-
before do
|
|
43
|
-
subject.check(url, foo: 'bar')
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'GET' do
|
|
47
|
-
subject do
|
|
48
|
-
described_class.new(methods: ['GET'])
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context 'check' do
|
|
52
|
-
context '200', vcr: { cassette_name: '200' } do
|
|
53
|
-
it 'passes metadata' do
|
|
54
|
-
expect(result.options).to eq(foo: 'bar')
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context '404', vcr: { cassette_name: '404' } do
|
|
59
|
-
it 'passes metadata' do
|
|
60
|
-
expect(result.options).to eq(foo: 'bar')
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
context 'error', vcr: { cassette_name: '404' } do
|
|
65
|
-
let(:url) { '\/invalid-url' }
|
|
66
|
-
|
|
67
|
-
it 'passes metadata' do
|
|
68
|
-
expect(result.options).to eq(foo: 'bar')
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
context 'a redirect loop', vcr: { cassette_name: '301+301' } do
|
|
73
|
-
it 'passes metadata' do
|
|
74
|
-
expect(result.options).to eq(foo: 'bar')
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context 'without results' do
|
|
82
|
-
before do
|
|
83
|
-
subject.check(url, foo: 'bar')
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context 'GET' do
|
|
87
|
-
subject do
|
|
88
|
-
described_class.new(results: false, methods: ['GET'])
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context 'check' do
|
|
92
|
-
context 'a valid URI that returns a 200', vcr: { cassette_name: '200' } do
|
|
93
|
-
it 'passes metadata' do
|
|
94
|
-
expect(subject.results).to be_nil
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context 'without metadata' do
|
|
102
|
-
before do
|
|
103
|
-
subject.check(url)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context 'GET' do
|
|
107
|
-
subject do
|
|
108
|
-
described_class.new(methods: ['GET'])
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
context 'check' do
|
|
112
|
-
context 'a valid URI that returns a 200', vcr: { cassette_name: '200' } do
|
|
113
|
-
it 'sets user agent' do
|
|
114
|
-
expect(result.request_headers['User-Agent']).to eq "Ruby Link Checker/#{LinkChecker::VERSION}"
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it 'returns all metadata' do
|
|
118
|
-
expect(result.options).to eq({})
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
context 'with custom headers' do
|
|
122
|
-
subject do
|
|
123
|
-
described_class.new(methods: ['GET'], headers: { 'DNT' => '1' })
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it 'sends custom headers' do
|
|
127
|
-
expect(result.request_headers['DNT']).to eq '1'
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it 'returns results' do
|
|
132
|
-
expect(subject.results).to eq(
|
|
133
|
-
error: [],
|
|
134
|
-
failure: [],
|
|
135
|
-
success: [
|
|
136
|
-
result
|
|
137
|
-
]
|
|
138
|
-
)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it 'succeeds' do
|
|
142
|
-
expect(result.success?).to be true
|
|
143
|
-
expect(result.error?).to be false
|
|
144
|
-
expect(result.failure?).to be false
|
|
145
|
-
expect(result.uri).to eq URI(url)
|
|
146
|
-
expect(subject).to have_received(:called!).with(:result, result)
|
|
147
|
-
expect(subject).to have_received(:called!).with(:success, result)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
context 'a 404', vcr: { cassette_name: '404', allow_playback_repeats: true } do
|
|
152
|
-
it 'fails' do
|
|
153
|
-
expect(result.success?).to be false
|
|
154
|
-
expect(result.error?).to be false
|
|
155
|
-
expect(result.failure?).to be true
|
|
156
|
-
expect(result.uri).to eq URI(url)
|
|
157
|
-
expect(result.response.code.to_i).to eq 404
|
|
158
|
-
expect(subject).to have_received(:called!).with(:failure, result)
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
context 'with 0 retries' do
|
|
162
|
-
subject do
|
|
163
|
-
described_class.new(methods: ['GET'], retries: 0)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it 'fails' do
|
|
167
|
-
expect(result.success?).to be false
|
|
168
|
-
expect(result.error?).to be false
|
|
169
|
-
expect(result.failure?).to be true
|
|
170
|
-
expect(result.uri).to eq URI(url)
|
|
171
|
-
expect(result.response.code.to_i).to eq 404
|
|
172
|
-
expect(subject).to have_received(:called!).with(:failure, result).once
|
|
173
|
-
expect(subject).not_to have_received(:called!).with(:retry, anything)
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
context 'with 1 retry' do
|
|
178
|
-
subject do
|
|
179
|
-
described_class.new(methods: ['GET'], retries: 1)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
it 'fails' do
|
|
183
|
-
expect(result.success?).to be false
|
|
184
|
-
expect(result.error?).to be false
|
|
185
|
-
expect(result.failure?).to be true
|
|
186
|
-
expect(result.uri).to eq URI(url)
|
|
187
|
-
expect(result.response.code.to_i).to eq 404
|
|
188
|
-
expect(subject).to have_received(:called!).with(:failure, result).once
|
|
189
|
-
expect(subject).to have_received(:called!).with(:retry, anything).once
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context 'with 2 retries' do
|
|
194
|
-
subject do
|
|
195
|
-
described_class.new(methods: ['GET'], retries: 2)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it 'fails' do
|
|
199
|
-
expect(result.success?).to be false
|
|
200
|
-
expect(result.error?).to be false
|
|
201
|
-
expect(result.failure?).to be true
|
|
202
|
-
expect(result.uri).to eq URI(url)
|
|
203
|
-
expect(result.response.code.to_i).to eq 404
|
|
204
|
-
expect(subject).to have_received(:called!).with(:failure, result).once
|
|
205
|
-
expect(subject).to have_received(:called!).with(:retry, anything).twice
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
context 'a redirect on HEAD followed by a 403', vcr: { cassette_name: '301+403' } do
|
|
211
|
-
it 'calls redirect callback' do
|
|
212
|
-
expect(result.success?).to be false
|
|
213
|
-
expect(result.failure?).to be true
|
|
214
|
-
expect(subject).to have_received(:called!).with(:redirect, anything)
|
|
215
|
-
expect(subject).to have_received(:called!).with(:failure, result).once
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
it 'reports its original and result urls' do
|
|
219
|
-
expect(result.uri.to_s).to eq url
|
|
220
|
-
expect(result.result_uri.to_s).not_to eq url
|
|
221
|
-
expect(result.result_uri.to_s).to eq 'https://www.dblock.org/'
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
context 'a redirect on HEAD followed by a 200', vcr: { cassette_name: '301+200' } do
|
|
226
|
-
it 'calls redirect callback' do
|
|
227
|
-
expect(result.success?).to be true
|
|
228
|
-
expect(result.failure?).to be false
|
|
229
|
-
expect(result.redirect?).to be false
|
|
230
|
-
expect(subject).to have_received(:called!).with(:redirect, anything)
|
|
231
|
-
expect(subject).to have_received(:called!).with(:success, result)
|
|
232
|
-
expect(subject).not_to have_received(:called!).with(:failure, anything)
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
context 'a redirect loop', vcr: { cassette_name: '301+301' } do
|
|
237
|
-
it 'calls redirect callback' do
|
|
238
|
-
expect(result.success?).to be false
|
|
239
|
-
expect(result.failure?).to be false
|
|
240
|
-
expect(result.error?).to be true
|
|
241
|
-
expect(result.error).to be_a LinkChecker::Errors::RedirectLoopError
|
|
242
|
-
expect(result.redirect?).to be false
|
|
243
|
-
expect(subject).to have_received(:called!).with(:redirect, anything).twice
|
|
244
|
-
expect(subject).to have_received(:called!).with(:error, result)
|
|
245
|
-
expect(subject).not_to have_received(:called!).with(:failure, result)
|
|
246
|
-
expect(subject).not_to have_received(:called!).with(:success, result)
|
|
247
|
-
end
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
context 'a retry on 429', vcr: {
|
|
251
|
-
cassette_name: '429+200',
|
|
252
|
-
match_requests_on: [lambda { |_request, recorded_request|
|
|
253
|
-
@matched ||= []
|
|
254
|
-
if @matched.size + 1 === recorded_request.headers['Index'].first
|
|
255
|
-
@matched << recorded_request
|
|
256
|
-
true
|
|
257
|
-
else
|
|
258
|
-
false
|
|
259
|
-
end
|
|
260
|
-
}]
|
|
261
|
-
} do
|
|
262
|
-
subject do
|
|
263
|
-
described_class.new(methods: ['GET'], retries: 1)
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
it 'calls a retry callback' do
|
|
267
|
-
expect(result.success?).to be true
|
|
268
|
-
expect(result.failure?).to be false
|
|
269
|
-
expect(result.redirect?).to be false
|
|
270
|
-
expect(subject).to have_received(:called!).with(:retry, anything)
|
|
271
|
-
expect(subject).to have_received(:called!).with(:success, result)
|
|
272
|
-
expect(subject).not_to have_received(:called!).with(:failure, anything)
|
|
273
|
-
expect(subject).not_to have_received(:called!).with(:error, anything)
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
context 'a failed retry on a redirect', vcr: { cassette_name: '308+429', allow_playback_repeats: true } do
|
|
278
|
-
subject do
|
|
279
|
-
described_class.new(methods: %w[HEAD], retries: 2)
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
it 'calls redirect callback' do
|
|
283
|
-
expect(result.success?).to be false
|
|
284
|
-
expect(result.failure?).to be true
|
|
285
|
-
expect(result.error?).to be false
|
|
286
|
-
expect(result.error).not_to be_a LinkChecker::Errors::RedirectLoopError
|
|
287
|
-
end
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
context 'an invalid URI' do
|
|
291
|
-
let(:url) { '\/invalid-url' }
|
|
292
|
-
|
|
293
|
-
it 'fails' do
|
|
294
|
-
expect(result.success?).to be false
|
|
295
|
-
expect(result.failure?).to be false
|
|
296
|
-
expect(result.error?).to be true
|
|
297
|
-
expect(result.uri).to eq url
|
|
298
|
-
expect(subject).to have_received(:called!).with(:result, result)
|
|
299
|
-
expect(subject).to have_received(:called!).with(:error, result)
|
|
300
|
-
expect(subject).not_to have_received(:called!).with(:failure)
|
|
301
|
-
expect(subject).not_to have_received(:called!).with(:success)
|
|
302
|
-
end
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
context 'HEAD,GET' do
|
|
307
|
-
subject do
|
|
308
|
-
described_class.new(methods: %w[HEAD GET])
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
context 'a valid URI that fails on HEAD and succeeds on GET', vcr: { cassette_name: '404+200' } do
|
|
312
|
-
it 'succeeds' do
|
|
313
|
-
expect(result.success?).to be true
|
|
314
|
-
expect(result.error?).to be false
|
|
315
|
-
expect(result.failure?).to be false
|
|
316
|
-
expect(result.uri).to eq URI(url)
|
|
317
|
-
expect(subject).to have_received(:called!).with(:success, result)
|
|
318
|
-
expect(subject).not_to have_received(:called!).with(:failure, result)
|
|
319
|
-
end
|
|
320
|
-
end
|
|
321
|
-
|
|
322
|
-
context 'a valid URI that fails both on HEAD and GET', vcr: { cassette_name: '404+404' } do
|
|
323
|
-
it 'fails' do
|
|
324
|
-
expect(result.success?).to be false
|
|
325
|
-
expect(result.error?).to be false
|
|
326
|
-
expect(result.failure?).to be true
|
|
327
|
-
expect(result.uri).to eq URI(url)
|
|
328
|
-
expect(result.response.code.to_i).to eq 404
|
|
329
|
-
expect(subject).to have_received(:called!).with(:failure, result).once
|
|
330
|
-
end
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
context 'a retry on 429', vcr: {
|
|
334
|
-
cassette_name: '429+429+200',
|
|
335
|
-
match_requests_on: [lambda { |request, recorded_request|
|
|
336
|
-
@matched ||= []
|
|
337
|
-
if recorded_request.method == request.method && @matched.size + 1 === recorded_request.headers['Index'].first
|
|
338
|
-
@matched << recorded_request
|
|
339
|
-
true
|
|
340
|
-
else
|
|
341
|
-
false
|
|
342
|
-
end
|
|
343
|
-
}]
|
|
344
|
-
} do
|
|
345
|
-
subject do
|
|
346
|
-
described_class.new(methods: %w[HEAD GET], retries: 1)
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
it 'executes HEAD twice, then falls back to GET' do
|
|
350
|
-
expect(result.success?).to be true
|
|
351
|
-
end
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
context 'a redirect on HEAD followed by a 400 error succeeds on GET',
|
|
355
|
-
vcr: { cassette_name: '301+400+301+200' } do
|
|
356
|
-
it 'calls redirect callback' do
|
|
357
|
-
expect(result.success?).to be true
|
|
358
|
-
expect(result.failure?).to be false
|
|
359
|
-
expect(result.redirect?).to be false
|
|
360
|
-
expect(subject).to have_received(:called!).with(:redirect, anything).twice
|
|
361
|
-
expect(subject).to have_received(:called!).with(:success, result).once
|
|
362
|
-
expect(subject).not_to have_received(:called!).with(:failure, anything)
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
end
|
|
366
|
-
end
|
|
367
|
-
end
|
|
368
|
-
end
|
|
369
|
-
end
|
data/spec/support/vcr.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'vcr'
|
|
4
|
-
require 'webmock/rspec'
|
|
5
|
-
|
|
6
|
-
VCR.configure do |config|
|
|
7
|
-
config.cassette_library_dir = 'spec/fixtures'
|
|
8
|
-
# config.default_cassette_options = { record: :new_episodes }
|
|
9
|
-
config.configure_rspec_metadata!
|
|
10
|
-
config.before_record do |i|
|
|
11
|
-
i.response.body.force_encoding('UTF-8')
|
|
12
|
-
end
|
|
13
|
-
end
|
data/spec/support/with_result.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
shared_context 'with result' do
|
|
2
|
-
before do
|
|
3
|
-
allow(subject).to receive(:called!)
|
|
4
|
-
subject.on do |event, *data|
|
|
5
|
-
subject.called! event, *data
|
|
6
|
-
end
|
|
7
|
-
subject.on :result do |result|
|
|
8
|
-
@result = result
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
let(:result) do
|
|
13
|
-
@result
|
|
14
|
-
end
|
|
15
|
-
end
|
data/spec/support/with_url.rb
DELETED