remote_http_testing 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/remote_http_testing/version.rb +1 -1
- data/lib/remote_http_testing.rb +14 -2
- metadata +4 -4
data/lib/remote_http_testing.rb
CHANGED
@@ -28,6 +28,18 @@ module RemoteHttpTesting
|
|
28
28
|
@json_response ||= JSON.parse(last_response.body)
|
29
29
|
end
|
30
30
|
|
31
|
+
# Temporarily make requests to a different server than the one specified by your server() method.
|
32
|
+
def use_server(server, &block)
|
33
|
+
@temporary_server = server
|
34
|
+
begin
|
35
|
+
yield
|
36
|
+
ensure
|
37
|
+
@temporary_server = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def current_server() (@temporary_server || self.server) end
|
42
|
+
|
31
43
|
# Prints out an error message and exits the program (to avoid running subsequent tests which are just
|
32
44
|
# going to fail) if the server is not reachable.
|
33
45
|
def ensure_reachable!(server_url, server_display_name = nil)
|
@@ -77,13 +89,13 @@ module RemoteHttpTesting
|
|
77
89
|
|
78
90
|
def perform_request(url, http_method, params = {}, request_body = nil)
|
79
91
|
self.last_response = @dom_response = @json_response = nil
|
80
|
-
url =
|
92
|
+
url = current_server + url
|
81
93
|
uri = URI.parse(url)
|
82
94
|
self.last_request = create_request(url, http_method, params, request_body)
|
83
95
|
begin
|
84
96
|
response = Net::HTTP.new(uri.host, uri.port).request(self.last_request)
|
85
97
|
rescue Errno::ECONNREFUSED => error
|
86
|
-
raise "Unable to connect to #{self.
|
98
|
+
raise "Unable to connect to #{self.current_server}"
|
87
99
|
end
|
88
100
|
self.last_response = response
|
89
101
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_http_testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phil Crosby
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-03-01 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|