alovak-network 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/network/connection.rb +1 -10
- data/test/network/test_connection.rb +0 -13
- metadata +7 -6
data/lib/network/connection.rb
CHANGED
@@ -43,7 +43,7 @@ module Network
|
|
43
43
|
response = http.post(uri.path, data, post_headers(data))
|
44
44
|
end
|
45
45
|
log_response(response, ms)
|
46
|
-
|
46
|
+
response
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -66,15 +66,6 @@ module Network
|
|
66
66
|
http
|
67
67
|
end
|
68
68
|
|
69
|
-
def handle_response(response)
|
70
|
-
case response.code.to_i
|
71
|
-
when 200...300
|
72
|
-
response.body
|
73
|
-
else
|
74
|
-
raise ResponseError.new(response)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
69
|
def try_request(&block)
|
79
70
|
begin
|
80
71
|
block.call
|
@@ -85,23 +85,10 @@ class TestConnection < Test::Unit::TestCase
|
|
85
85
|
@connection.expects(:log_request).in_sequence(sec)
|
86
86
|
@connection.expects(:http).in_sequence(sec).returns(stub('http', :post => true))
|
87
87
|
@connection.expects(:log_response).in_sequence(sec)
|
88
|
-
@connection.expects(:handle_response).in_sequence(sec)
|
89
88
|
|
90
89
|
@connection.post("hello")
|
91
90
|
end
|
92
91
|
|
93
|
-
def test_response_handler_raises_response_error_if_response_code_not_in_200_299
|
94
|
-
[300, 400, 500].each do |code|
|
95
|
-
assert_raise Network::ResponseError do
|
96
|
-
@connection.send(:handle_response, ResponseStub.new(code))
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_response_handler_returns_response_body_if_response_code_200_299
|
102
|
-
assert_equal "response", @connection.send(:handle_response, ResponseStub.new(200, "OK", "response"))
|
103
|
-
end
|
104
|
-
|
105
92
|
def test_default_timeouts
|
106
93
|
assert_equal Network::Connection::READ_TIMEOUT, @connection.read_timeout
|
107
94
|
assert_equal Network::Connection::OPEN_TIMEOUT, @connection.open_timeout
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alovak-network
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Gabriel
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-14 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - "
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.9.7
|
24
24
|
version:
|
@@ -33,9 +33,10 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- lib/network/connection.rb
|
35
35
|
- lib/network.rb
|
36
|
-
has_rdoc:
|
36
|
+
has_rdoc: true
|
37
37
|
homepage: http://github.com/alovak/network/
|
38
|
-
licenses:
|
38
|
+
licenses: []
|
39
|
+
|
39
40
|
post_install_message:
|
40
41
|
rdoc_options: []
|
41
42
|
|
@@ -58,7 +59,7 @@ requirements: []
|
|
58
59
|
rubyforge_project:
|
59
60
|
rubygems_version: 1.3.5
|
60
61
|
signing_key:
|
61
|
-
specification_version:
|
62
|
+
specification_version: 3
|
62
63
|
summary: HTTP/HTTPS communication module based on ruby net/http, net/https modules
|
63
64
|
test_files:
|
64
65
|
- test/network/test_network.rb
|