httpi 0.9.3 → 0.9.4
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.
- data/.travis.yml +7 -0
- data/CHANGELOG.md +14 -1
- data/Gemfile +5 -3
- data/README.md +130 -100
- data/Rakefile +10 -40
- data/httpi.gemspec +11 -13
- data/lib/httpi.rb +5 -0
- data/lib/httpi/adapter.rb +17 -13
- data/lib/httpi/auth/ssl.rb +4 -4
- data/lib/httpi/request.rb +1 -1
- data/lib/httpi/version.rb +1 -1
- data/spec/httpi/adapter/curb_spec.rb +167 -164
- data/spec/httpi/adapter/httpclient_spec.rb +16 -16
- data/spec/httpi/adapter_spec.rb +29 -15
- data/spec/httpi/auth/config_spec.rb +16 -16
- data/spec/httpi/auth/ssl_spec.rb +19 -19
- data/spec/httpi/httpi_spec.rb +44 -53
- data/spec/httpi/request_spec.rb +15 -15
- data/spec/httpi/response_spec.rb +17 -17
- metadata +34 -50
data/spec/httpi/request_spec.rb
CHANGED
@@ -5,12 +5,12 @@ describe HTTPI::Request do
|
|
5
5
|
let(:request) { HTTPI::Request.new }
|
6
6
|
|
7
7
|
describe ".new" do
|
8
|
-
it "
|
8
|
+
it "accepts a url" do
|
9
9
|
request = HTTPI::Request.new "http://example.com"
|
10
10
|
request.url.should == URI("http://example.com")
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "accepts a Hash of accessors to set" do
|
14
14
|
request = HTTPI::Request.new :url => "http://example.com", :open_timeout => 30
|
15
15
|
request.url.should == URI("http://example.com")
|
16
16
|
request.open_timeout.should == 30
|
@@ -28,8 +28,8 @@ describe HTTPI::Request do
|
|
28
28
|
request.url.should == URI("http://example.com")
|
29
29
|
end
|
30
30
|
|
31
|
-
it "raises an ArgumentError in case
|
32
|
-
|
31
|
+
it "raises an ArgumentError in case of an invalid url" do
|
32
|
+
expect { request.url = "invalid" }.to raise_error(ArgumentError)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -44,28 +44,28 @@ describe HTTPI::Request do
|
|
44
44
|
request.proxy.should == URI("http://proxy.example.com")
|
45
45
|
end
|
46
46
|
|
47
|
-
it "raises an ArgumentError in case
|
48
|
-
|
47
|
+
it "raises an ArgumentError in case of an invalid url" do
|
48
|
+
expect { request.proxy = "invalid" }.to raise_error(ArgumentError)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "#ssl" do
|
53
|
-
it "
|
53
|
+
it "returns false if no request url was specified" do
|
54
54
|
request.should_not be_ssl
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "returns false if the request url does not start with https" do
|
58
58
|
request.url = "http://example.com"
|
59
59
|
request.should_not be_ssl
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "returns true if the request url starts with https" do
|
63
63
|
request.url = "https://example.com"
|
64
64
|
request.should be_ssl
|
65
65
|
end
|
66
66
|
|
67
67
|
context "with an explicit value" do
|
68
|
-
it "
|
68
|
+
it "returns the value" do
|
69
69
|
request.ssl = true
|
70
70
|
request.should be_ssl
|
71
71
|
end
|
@@ -84,7 +84,7 @@ describe HTTPI::Request do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "#gzip" do
|
87
|
-
it "
|
87
|
+
it "adds the proper 'Accept-Encoding' header" do
|
88
88
|
request.gzip
|
89
89
|
request.headers["Accept-Encoding"].should == "gzip,deflate"
|
90
90
|
end
|
@@ -112,22 +112,22 @@ describe HTTPI::Request do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "#auth" do
|
115
|
-
it "
|
115
|
+
it "returns the authentication object" do
|
116
116
|
request.auth.should be_an(HTTPI::Auth::Config)
|
117
117
|
end
|
118
118
|
|
119
|
-
it "
|
119
|
+
it "memoizes the authentication object" do
|
120
120
|
request.auth.should equal(request.auth)
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
describe "#auth?" do
|
125
|
-
it "
|
125
|
+
it "returns true when auth credentials are specified" do
|
126
126
|
request.auth.basic "username", "password"
|
127
127
|
request.auth?.should be_true
|
128
128
|
end
|
129
129
|
|
130
|
-
it "
|
130
|
+
it "returns false otherwise" do
|
131
131
|
request.auth?.should be_false
|
132
132
|
end
|
133
133
|
end
|
data/spec/httpi/response_spec.rb
CHANGED
@@ -7,30 +7,30 @@ describe HTTPI::Response do
|
|
7
7
|
let(:response) { HTTPI::Response.new 200, {}, Fixture.xml }
|
8
8
|
|
9
9
|
describe "#error?" do
|
10
|
-
it "
|
10
|
+
it "returns false" do
|
11
11
|
response.should_not be_an_error
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#headers" do
|
16
|
-
it "
|
16
|
+
it "returns the HTTP response headers" do
|
17
17
|
response.headers.should == {}
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#code" do
|
22
|
-
it "
|
22
|
+
it "returns the HTTP response code" do
|
23
23
|
response.code.should == 200
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "always returns an Integer" do
|
27
27
|
response = HTTPI::Response.new "200", {}, ""
|
28
28
|
response.code.should == 200
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe "#multipart" do
|
33
|
-
it "
|
33
|
+
it "returns false" do
|
34
34
|
response.should_not be_multipart
|
35
35
|
end
|
36
36
|
end
|
@@ -40,7 +40,7 @@ describe HTTPI::Response do
|
|
40
40
|
let(:response) { HTTPI::Response.new 204, {}, nil }
|
41
41
|
|
42
42
|
describe "#body" do
|
43
|
-
it "
|
43
|
+
it "returns an empty String" do
|
44
44
|
response.body.should == ""
|
45
45
|
end
|
46
46
|
end
|
@@ -50,7 +50,7 @@ describe HTTPI::Response do
|
|
50
50
|
let(:response) { HTTPI::Response.new 200, { "Content-Type" => "multipart/related" }, "multipart" }
|
51
51
|
|
52
52
|
describe "#multipart" do
|
53
|
-
it "
|
53
|
+
it "returns true" do
|
54
54
|
response.should be_multipart
|
55
55
|
end
|
56
56
|
end
|
@@ -60,7 +60,7 @@ describe HTTPI::Response do
|
|
60
60
|
let(:response) { HTTPI::Response.new 404, {}, "" }
|
61
61
|
|
62
62
|
describe "#error?" do
|
63
|
-
it "
|
63
|
+
it "returns true" do
|
64
64
|
response.should be_an_error
|
65
65
|
end
|
66
66
|
end
|
@@ -70,25 +70,25 @@ describe HTTPI::Response do
|
|
70
70
|
let(:response) { HTTPI::Response.new 200, { "Content-Encoding" => "gzip" }, Fixture.gzip }
|
71
71
|
|
72
72
|
describe "#headers" do
|
73
|
-
it "
|
73
|
+
it "returns the HTTP response headers" do
|
74
74
|
response.headers.should == { "Content-Encoding" => "gzip" }
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "#body" do
|
79
|
-
it "
|
79
|
+
it "returns the (gzip decoded) HTTP response body" do
|
80
80
|
response.body.should == Fixture.xml
|
81
81
|
end
|
82
82
|
|
83
|
-
it "
|
83
|
+
it "bubbles Zlib errors" do
|
84
84
|
arbitrary_error = Class.new(ArgumentError)
|
85
85
|
Zlib::GzipReader.expects(:new).raises(arbitrary_error)
|
86
|
-
|
86
|
+
expect { response.body }.to raise_error(arbitrary_error)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#raw_body" do
|
91
|
-
it "
|
91
|
+
it "returns the raw HTML response body" do
|
92
92
|
response.raw_body.should == Fixture.gzip
|
93
93
|
end
|
94
94
|
end
|
@@ -98,25 +98,25 @@ describe HTTPI::Response do
|
|
98
98
|
let(:response) { HTTPI::Response.new 200, { "Content-Type" => "application/dime" }, Fixture.dime }
|
99
99
|
|
100
100
|
describe "#headers" do
|
101
|
-
it "
|
101
|
+
it "returns the HTTP response headers" do
|
102
102
|
response.headers.should == { "Content-Type" => "application/dime" }
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe "#body" do
|
107
|
-
it "
|
107
|
+
it "returns the (dime decoded) HTTP response body" do
|
108
108
|
response.body.should == Fixture.xml_dime
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
describe "#raw_body" do
|
113
|
-
it "
|
113
|
+
it "returns the raw HTML response body" do
|
114
114
|
response.raw_body.should == Fixture.dime
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "#attachments" do
|
119
|
-
it "
|
119
|
+
it "returns proper attachment when given a dime response" do
|
120
120
|
response.attachments.first.data == File.read(File.expand_path("../../fixtures/attachment.gif", __FILE__))
|
121
121
|
end
|
122
122
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 4
|
10
|
+
version: 0.9.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
20
|
-
default_executable:
|
19
|
+
date: 2011-05-15 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: rack
|
@@ -34,57 +33,26 @@ dependencies:
|
|
34
33
|
type: :runtime
|
35
34
|
version_requirements: *id001
|
36
35
|
- !ruby/object:Gem::Dependency
|
37
|
-
name: ntlm-http
|
36
|
+
name: pyu-ntlm-http
|
38
37
|
prerelease: false
|
39
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ">="
|
43
42
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
43
|
+
hash: 73
|
45
44
|
segments:
|
46
45
|
- 0
|
47
46
|
- 1
|
47
|
+
- 3
|
48
48
|
- 1
|
49
|
-
version: 0.1.1
|
49
|
+
version: 0.1.3.1
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: httpclient
|
54
|
-
prerelease: false
|
55
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
|
-
requirements:
|
58
|
-
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 5
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 1
|
64
|
-
- 7
|
65
|
-
version: 2.1.7
|
66
|
-
type: :development
|
67
|
-
version_requirements: *id003
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: curb
|
70
|
-
prerelease: false
|
71
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
|
-
requirements:
|
74
|
-
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
hash: 19
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
- 7
|
80
|
-
- 8
|
81
|
-
version: 0.7.8
|
82
|
-
type: :development
|
83
|
-
version_requirements: *id004
|
84
52
|
- !ruby/object:Gem::Dependency
|
85
53
|
name: rspec
|
86
54
|
prerelease: false
|
87
|
-
requirement: &
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
88
56
|
none: false
|
89
57
|
requirements:
|
90
58
|
- - ~>
|
@@ -95,11 +63,11 @@ dependencies:
|
|
95
63
|
- 2
|
96
64
|
version: "2.2"
|
97
65
|
type: :development
|
98
|
-
version_requirements: *
|
66
|
+
version_requirements: *id003
|
99
67
|
- !ruby/object:Gem::Dependency
|
100
68
|
name: autotest
|
101
69
|
prerelease: false
|
102
|
-
requirement: &
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
103
71
|
none: false
|
104
72
|
requirements:
|
105
73
|
- - ">="
|
@@ -109,11 +77,11 @@ dependencies:
|
|
109
77
|
- 0
|
110
78
|
version: "0"
|
111
79
|
type: :development
|
112
|
-
version_requirements: *
|
80
|
+
version_requirements: *id004
|
113
81
|
- !ruby/object:Gem::Dependency
|
114
82
|
name: mocha
|
115
83
|
prerelease: false
|
116
|
-
requirement: &
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
117
85
|
none: false
|
118
86
|
requirements:
|
119
87
|
- - ~>
|
@@ -125,11 +93,11 @@ dependencies:
|
|
125
93
|
- 9
|
126
94
|
version: 0.9.9
|
127
95
|
type: :development
|
128
|
-
version_requirements: *
|
96
|
+
version_requirements: *id005
|
129
97
|
- !ruby/object:Gem::Dependency
|
130
98
|
name: webmock
|
131
99
|
prerelease: false
|
132
|
-
requirement: &
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
133
101
|
none: false
|
134
102
|
requirements:
|
135
103
|
- - ~>
|
@@ -141,7 +109,23 @@ dependencies:
|
|
141
109
|
- 0
|
142
110
|
version: 1.4.0
|
143
111
|
type: :development
|
144
|
-
version_requirements: *
|
112
|
+
version_requirements: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: mock-server
|
115
|
+
prerelease: false
|
116
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ~>
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 25
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
- 1
|
125
|
+
- 1
|
126
|
+
version: 0.1.1
|
127
|
+
type: :development
|
128
|
+
version_requirements: *id007
|
145
129
|
description: HTTPI provides a common interface for Ruby HTTP libraries.
|
146
130
|
email: me@rubiii.com
|
147
131
|
executables: []
|
@@ -155,6 +139,7 @@ files:
|
|
155
139
|
- .gemtest
|
156
140
|
- .gitignore
|
157
141
|
- .rspec
|
142
|
+
- .travis.yml
|
158
143
|
- CHANGELOG.md
|
159
144
|
- Gemfile
|
160
145
|
- LICENSE
|
@@ -194,7 +179,6 @@ files:
|
|
194
179
|
- spec/spec_helper.rb
|
195
180
|
- spec/support/fixture.rb
|
196
181
|
- spec/support/matchers.rb
|
197
|
-
has_rdoc: true
|
198
182
|
homepage: http://github.com/rubiii/httpi
|
199
183
|
licenses: []
|
200
184
|
|
@@ -224,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
208
|
requirements: []
|
225
209
|
|
226
210
|
rubyforge_project: httpi
|
227
|
-
rubygems_version: 1.
|
211
|
+
rubygems_version: 1.7.2
|
228
212
|
signing_key:
|
229
213
|
specification_version: 3
|
230
214
|
summary: Interface for Ruby HTTP libraries
|