testbeat 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/spec_helper.rb +28 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f351005ad9c8613e13e6b8149aaa3575166ea5ff
|
4
|
+
data.tar.gz: 4dedca6c54209fb5914b5bef5dd13b2b8caf1a64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6afa9b30143d299cd97fe9ffe6ce6f4f1fe3717c4c0c2c30f4fc36742711906616af75f14c5ae13875057e4e9cdacd9eeaca8c51b0e4cb3ff1435c29ad5eb235
|
7
|
+
data.tar.gz: c894dd8624444cd387b3930d094791700375f060f3f654e0e39d3ae92fddb92399df417712aeaa204c00eccb3b67b8b6d3d0b69973576dabbe02cd688f6625ed
|
data/lib/rspec/spec_helper.rb
CHANGED
@@ -273,6 +273,14 @@ class TestbeatContext
|
|
273
273
|
@method
|
274
274
|
end
|
275
275
|
|
276
|
+
def redirect
|
277
|
+
@rest_redirect
|
278
|
+
end
|
279
|
+
|
280
|
+
def redirect?
|
281
|
+
!!redirect
|
282
|
+
end
|
283
|
+
|
276
284
|
def port
|
277
285
|
@rest_port
|
278
286
|
end
|
@@ -354,6 +362,9 @@ class TestbeatContext
|
|
354
362
|
if example_group[:port]
|
355
363
|
@rest_port = example_group[:port]
|
356
364
|
end
|
365
|
+
if example_group[:redirect]
|
366
|
+
@rest_redirect = example_group[:redirect]
|
367
|
+
end
|
357
368
|
end
|
358
369
|
|
359
370
|
end
|
@@ -438,6 +449,23 @@ class TestbeatRestRequest
|
|
438
449
|
|
439
450
|
@response = http.request(req) # Net::HTTPResponse object
|
440
451
|
|
452
|
+
# The redirect must not be authenticated. Consider copying 401 handling to above redirect handling.
|
453
|
+
# Follows a single redirect, no recursive redirects (a feature in a test framework).
|
454
|
+
if (@response.code == "301" or @response.code == "302") and @testbeat.redirect
|
455
|
+
@testbeat.logger.info{ "Redirecting #{@response.code} to #{@response['location']}" }
|
456
|
+
redirectTo = URI.parse(@response['location'])
|
457
|
+
redirectToPath = [redirectTo.path,redirectTo.query].join('?')
|
458
|
+
#reqRedirect = req.new(redirectTo.path, req.to_hash()) # new(path, initheader = nil)
|
459
|
+
reqRedirect = HTTP_VERBS[@testbeat.method].new(redirectToPath) # new(path, initheader = nil)
|
460
|
+
if @testbeat.headers?
|
461
|
+
@testbeat.headers.each {|name, value| reqRedirect[name] = value }
|
462
|
+
end
|
463
|
+
reqRedirect.body = req.body
|
464
|
+
@response = http.request(reqRedirect)
|
465
|
+
req = reqRedirect # Needed by auth support below.
|
466
|
+
@testbeat.logger.info{ "Redirected #{@response.code}" }
|
467
|
+
end
|
468
|
+
|
441
469
|
if @response.code == "401" and @testbeat.user and not @testbeat.unauthenticated?
|
442
470
|
u = @testbeat.user
|
443
471
|
@testbeat.logger.info{ "Authenticating to #{@testbeat.resource} with #{u[:username]}:#{u[:password]}" }
|