cs-httpi 0.9.5.1
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/.autotest +5 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +66 -0
- data/Gemfile +9 -0
- data/LICENSE +20 -0
- data/README.md +229 -0
- data/Rakefile +18 -0
- data/autotest/discover.rb +1 -0
- data/cs-httpi.gemspec +26 -0
- data/lib/cs-httpi.rb +198 -0
- data/lib/cs-httpi/adapter.rb +67 -0
- data/lib/cs-httpi/adapter/curb.rb +119 -0
- data/lib/cs-httpi/adapter/httpclient.rb +98 -0
- data/lib/cs-httpi/adapter/net_http.rb +115 -0
- data/lib/cs-httpi/auth/config.rb +78 -0
- data/lib/cs-httpi/auth/ssl.rb +91 -0
- data/lib/cs-httpi/dime.rb +56 -0
- data/lib/cs-httpi/request.rb +99 -0
- data/lib/cs-httpi/response.rb +85 -0
- data/lib/cs-httpi/version.rb +5 -0
- data/nbproject/private/private.properties +2 -0
- data/nbproject/private/rake-d.txt +0 -0
- data/nbproject/project.properties +7 -0
- data/nbproject/project.xml +15 -0
- data/spec/cs-httpi/adapter/curb_spec.rb +232 -0
- data/spec/cs-httpi/adapter/httpclient_spec.rb +164 -0
- data/spec/cs-httpi/adapter/net_http_spec.rb +142 -0
- data/spec/cs-httpi/adapter_spec.rb +55 -0
- data/spec/cs-httpi/auth/config_spec.rb +117 -0
- data/spec/cs-httpi/auth/ssl_spec.rb +128 -0
- data/spec/cs-httpi/httpi_spec.rb +284 -0
- data/spec/cs-httpi/request_spec.rb +140 -0
- data/spec/cs-httpi/response_spec.rb +125 -0
- data/spec/fixtures/attachment.gif +0 -0
- data/spec/fixtures/client_cert.pem +16 -0
- data/spec/fixtures/client_key.pem +15 -0
- data/spec/fixtures/xml.gz +0 -0
- data/spec/fixtures/xml.xml +10 -0
- data/spec/fixtures/xml_dime.dime +0 -0
- data/spec/fixtures/xml_dime.xml +1 -0
- data/spec/integration/request_spec.rb +95 -0
- data/spec/integration/server.rb +39 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/fixture.rb +27 -0
- data/spec/support/matchers.rb +19 -0
- metadata +158 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "cs-httpi/response"
|
3
|
+
|
4
|
+
describe HTTPI::Response do
|
5
|
+
|
6
|
+
context "normal" do
|
7
|
+
let(:response) { HTTPI::Response.new 200, {}, Fixture.xml }
|
8
|
+
|
9
|
+
describe "#error?" do
|
10
|
+
it "returns false" do
|
11
|
+
response.should_not be_an_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#headers" do
|
16
|
+
it "returns the HTTP response headers" do
|
17
|
+
response.headers.should == {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#code" do
|
22
|
+
it "returns the HTTP response code" do
|
23
|
+
response.code.should == 200
|
24
|
+
end
|
25
|
+
|
26
|
+
it "always returns an Integer" do
|
27
|
+
response = HTTPI::Response.new "200", {}, ""
|
28
|
+
response.code.should == 200
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#multipart" do
|
33
|
+
it "returns false" do
|
34
|
+
response.should_not be_multipart
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "empty" do
|
40
|
+
let(:response) { HTTPI::Response.new 204, {}, nil }
|
41
|
+
|
42
|
+
describe "#body" do
|
43
|
+
it "returns an empty String" do
|
44
|
+
response.body.should == ""
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "multipart" do
|
50
|
+
let(:response) { HTTPI::Response.new 200, { "Content-Type" => "multipart/related" }, "multipart" }
|
51
|
+
|
52
|
+
describe "#multipart" do
|
53
|
+
it "returns true" do
|
54
|
+
response.should be_multipart
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "error" do
|
60
|
+
let(:response) { HTTPI::Response.new 404, {}, "" }
|
61
|
+
|
62
|
+
describe "#error?" do
|
63
|
+
it "returns true" do
|
64
|
+
response.should be_an_error
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "gzipped" do
|
70
|
+
let(:response) { HTTPI::Response.new 200, { "Content-Encoding" => "gzip" }, Fixture.gzip }
|
71
|
+
|
72
|
+
describe "#headers" do
|
73
|
+
it "returns the HTTP response headers" do
|
74
|
+
response.headers.should == { "Content-Encoding" => "gzip" }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#body" do
|
79
|
+
it "returns the (gzip decoded) HTTP response body" do
|
80
|
+
response.body.should == Fixture.xml
|
81
|
+
end
|
82
|
+
|
83
|
+
it "bubbles Zlib errors" do
|
84
|
+
arbitrary_error = Class.new(ArgumentError)
|
85
|
+
Zlib::GzipReader.expects(:new).raises(arbitrary_error)
|
86
|
+
expect { response.body }.to raise_error(arbitrary_error)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#raw_body" do
|
91
|
+
it "returns the raw HTML response body" do
|
92
|
+
response.raw_body.should == Fixture.gzip
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "DIME" do
|
98
|
+
let(:response) { HTTPI::Response.new 200, { "Content-Type" => "application/dime" }, Fixture.dime }
|
99
|
+
|
100
|
+
describe "#headers" do
|
101
|
+
it "returns the HTTP response headers" do
|
102
|
+
response.headers.should == { "Content-Type" => "application/dime" }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#body" do
|
107
|
+
it "returns the (dime decoded) HTTP response body" do
|
108
|
+
response.body.should == Fixture.xml_dime
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#raw_body" do
|
113
|
+
it "returns the raw HTML response body" do
|
114
|
+
response.raw_body.should == Fixture.dime
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "#attachments" do
|
119
|
+
it "returns proper attachment when given a dime response" do
|
120
|
+
response.attachments.first.data == File.read(File.expand_path("../../fixtures/attachment.gif", __FILE__))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIICbTCCAdYCCQDC4v8d04615DANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJE
|
3
|
+
RTEQMA4GA1UECBMHSGFtYnVyZzEQMA4GA1UEBxMHSGFtYnVyZzEOMAwGA1UEChMF
|
4
|
+
aHR0cGkxFDASBgNVBAMTC2V4YW1wbGUuY29tMSIwIAYJKoZIhvcNAQkBFhNleGFt
|
5
|
+
cGxlQGV4YW1wbGUuY29tMB4XDTEwMTAxNTE4NTg0N1oXDTExMTAxNTE4NTg0N1ow
|
6
|
+
ezELMAkGA1UEBhMCREUxEDAOBgNVBAgTB0hhbWJ1cmcxEDAOBgNVBAcTB0hhbWJ1
|
7
|
+
cmcxDjAMBgNVBAoTBWh0dHBpMRQwEgYDVQQDEwtleGFtcGxlLmNvbTEiMCAGCSqG
|
8
|
+
SIb3DQEJARYTZXhhbXBsZUBleGFtcGxlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOB
|
9
|
+
jQAwgYkCgYEAvJiaojIFQAbFczXkBmjxpxra9LbQm0VIESFSl8uBSjmG/gmCBwKg
|
10
|
+
8O94P3tAjDNClC+fEqBLE37KH4qe76yw7upgRruP5jQzUEL1yCaVtA/DoqgaCxZy
|
11
|
+
7VhB2A3f71Zw6kQPt3BOME68fnGsTX65x9XAawCGzGmJSk/Z6wvml1MCAwEAATAN
|
12
|
+
BgkqhkiG9w0BAQUFAAOBgQCxOyni9LOKf17vUKVG8Y4TBzRYwm8/hlEdVEU3JKG0
|
13
|
+
/aCCwIJLHl+z+3L4r81IN3+YKrHilqx9K0emboJbBRQklYsv/AE+J44Bq3llRiro
|
14
|
+
0e5zwH61jb1j+kxhcxoGiiy8R7hYho24ljuMgFGqtK3kZSP/t9tBLLVp+ItWQ6xX
|
15
|
+
5g==
|
16
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,15 @@
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
2
|
+
MIICXQIBAAKBgQC8mJqiMgVABsVzNeQGaPGnGtr0ttCbRUgRIVKXy4FKOYb+CYIH
|
3
|
+
AqDw73g/e0CMM0KUL58SoEsTfsofip7vrLDu6mBGu4/mNDNQQvXIJpW0D8OiqBoL
|
4
|
+
FnLtWEHYDd/vVnDqRA+3cE4wTrx+caxNfrnH1cBrAIbMaYlKT9nrC+aXUwIDAQAB
|
5
|
+
AoGBAKjrGh1KJg+pwPInA5yGJGMil5h1obRgwmKtcPeKi7u6eOFSDMdQoGwMYKyj
|
6
|
+
LTYlt21Yleat8XB9sHW9yAstpq5dU8Id2A4wfbJeaBYpek7u5+QwBENO4UrnulTk
|
7
|
+
W0d+jECBVYECn8wCStxfoFcQQRhlGrsOn05379cD8e1odMOJAkEA3o/7CsgXqahG
|
8
|
+
7L1HaWYtKnpFfTS+EQgdGvSahOolByAKTtMA2TUBU1FdlCk+ggWBGorqmWON5Qnm
|
9
|
+
7UDHjOasZQJBANjuPOqa9ubqHccGwHec+72pQz6q5e8f1gf1XPn7EEuXsBzYiMMH
|
10
|
+
qEa8zpfF0TmhQ0oWN75Cq709gfVVBfx/bVcCQHan1HN/Ef6FlKqKjxQGQXYwEfQa
|
11
|
+
tmpmJP5GAktyeaM+1cAIhp9GvxooeveOtaCkRpxcC48ToIbHrLI4oyrfoHECQQC6
|
12
|
+
bAHtmz6TMp5ka2j7Yez1EIC5WiQ/WxyTukgsi5V1YOX35B2jfPEf2SGxTE6BOBSb
|
13
|
+
lnxRBPqRpkoIiwiZ9OgBAkBOWKBuHXmXM6wr+0p4KQ/DOeStZiBxUT8rYbX/i1BI
|
14
|
+
/9Xo48KNerTx7qoDK+jIslDrilahvcwUz0fuVV7rHy/X
|
15
|
+
-----END RSA PRIVATE KEY-----
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ex="http://service.example.com/">
|
2
|
+
<soapenv:Header/>
|
3
|
+
<soapenv:Body>
|
4
|
+
<ex:findUser>
|
5
|
+
<request>
|
6
|
+
<id>1</id>
|
7
|
+
</request>
|
8
|
+
</ex:findUser>
|
9
|
+
</soapenv:Body>
|
10
|
+
</soapenv:Envelope>
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getFileResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><getFileReturn href="#id0"/></getFileResponse><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:FileVW" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://ws"><created xsi:type="xsd:dateTime">2010-10-27T22:00:00.000Z</created><id xsi:type="xsd:int">2181136</id><lastUpdated xsi:type="xsd:dateTime">2010-10-27T22:00:00.000Z</lastUpdated><metadata href="#id1"/><name xsi:type="xsd:string">attachment.gif</name><size xsi:type="xsd:long">80</size><type xsi:type="xsd:string">gif</type><version xsi:type="xsd:long">1</version></multiRef><multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:MetadataVW" xmlns:ns2="http://ws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><CR_Latest xsi:type="xsd:boolean">true</CR_Latest><MD5 xsi:type="xsd:string">0xC11FE5DB260A89160FFF4EC26630EEB8</MD5><PSize xsi:type="xsd:string" xsi:nil="true"/><category xsi:type="xsd:string">1</category><completionRate xsi:type="xsd:int">1</completionRate><date xsi:type="xsd:string" xsi:nil="true"/><docNo xsi:type="xsd:string"></docNo><filesId xsi:type="xsd:int">2181136</filesId><init xsi:type="xsd:string"></init><locked xsi:type="xsd:boolean">false</locked><mdate xsi:type="xsd:dateTime">2010-10-28T20:27:00.000Z</mdate><meta1 xsi:type="xsd:string" xsi:nil="true"/><meta10 xsi:type="xsd:string" xsi:nil="true"/><meta11 xsi:type="xsd:string" xsi:nil="true"/><meta12 xsi:type="xsd:string" xsi:nil="true"/><meta13 xsi:type="xsd:string" xsi:nil="true"/><meta14 xsi:type="xsd:string" xsi:nil="true"/><meta15 xsi:type="xsd:string" xsi:nil="true"/><meta16 xsi:type="xsd:string" xsi:nil="true"/><meta17 xsi:type="xsd:string" xsi:nil="true"/><meta18 xsi:type="xsd:string" xsi:nil="true"/><meta19 xsi:type="xsd:string" xsi:nil="true"/><meta2 xsi:type="xsd:string" xsi:nil="true"/><meta20 xsi:type="xsd:string" xsi:nil="true"/><meta3 xsi:type="xsd:string" xsi:nil="true"/><meta4 xsi:type="xsd:string" xsi:nil="true"/><meta5 xsi:type="xsd:string" xsi:nil="true"/><meta6 xsi:type="xsd:string" xsi:nil="true"/><meta7 xsi:type="xsd:string" xsi:nil="true"/><meta8 xsi:type="xsd:string" xsi:nil="true"/><meta9 xsi:type="xsd:string" xsi:nil="true"/><note xsi:type="xsd:string" xsi:nil="true"/><ref xsi:type="xsd:string"></ref><ref2 xsi:type="xsd:string" xsi:nil="true"/><ref3 xsi:type="xsd:string" xsi:nil="true"/><ref4 xsi:type="xsd:string" xsi:nil="true"/><revDate xsi:type="xsd:string"></revDate><revName xsi:type="xsd:string"></revName><scale xsi:type="xsd:string" xsi:nil="true"/><scaleUnit xsi:type="xsd:string" xsi:nil="true"/><size xsi:type="xsd:int">80</size><type xsi:type="xsd:string">Document</type><version xsi:type="xsd:int">1</version></multiRef></soapenv:Body></soapenv:Envelope>
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "httpi"
|
3
|
+
require "integration/server"
|
4
|
+
|
5
|
+
MockServer.new(IntegrationServer, 4000).start
|
6
|
+
|
7
|
+
describe HTTPI do
|
8
|
+
let(:client) { HTTPI }
|
9
|
+
|
10
|
+
before :all do
|
11
|
+
WebMock.allow_net_connect!
|
12
|
+
|
13
|
+
@username = "admin"
|
14
|
+
@password = "pwd"
|
15
|
+
@error_message = "Authorization Required"
|
16
|
+
@example_web_page = "Hello"
|
17
|
+
@content_type = "text/plain"
|
18
|
+
end
|
19
|
+
|
20
|
+
shared_examples_for "an HTTP client" do
|
21
|
+
it "and send HTTP headers" do
|
22
|
+
request = HTTPI::Request.new :url => "http://localhost:4000/x-header"
|
23
|
+
request.headers["X-Header"] = "HTTPI"
|
24
|
+
|
25
|
+
response = HTTPI.get request, adapter
|
26
|
+
response.body.should include("X-Header is HTTPI")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "and execute an HTTP GET request" do
|
30
|
+
response = HTTPI.get "http://localhost:4000", adapter
|
31
|
+
response.body.should include(@example_web_page)
|
32
|
+
response.headers["Content-Type"].should include(@content_type)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "and execute an HTTP POST request" do
|
36
|
+
response = HTTPI.post "http://localhost:4000", "<some>xml</some>", adapter
|
37
|
+
response.body.should include(@example_web_page)
|
38
|
+
response.headers["Content-Type"].should include(@content_type)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "and execute an HTTP HEAD request" do
|
42
|
+
response = HTTPI.head "http://localhost:4000", adapter
|
43
|
+
response.code.should == 200
|
44
|
+
response.headers["Content-Type"].should include(@content_type)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "and execute an HTTP PUT request" do
|
48
|
+
response = HTTPI.put "http://localhost:4000", "<some>xml</some>", adapter
|
49
|
+
response.body.should include("PUT is not allowed")
|
50
|
+
response.headers["Content-Type"].should include(@content_type)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "and execute an HTTP DELETE request" do
|
54
|
+
response = HTTPI.delete "http://localhost:4000", adapter
|
55
|
+
response.body.should include("DELETE is not allowed")
|
56
|
+
response.headers["Content-Type"].should include(@content_type)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
shared_examples_for "it works with HTTP basic auth" do
|
61
|
+
it "and access a secured page" do
|
62
|
+
request = HTTPI::Request.new :url => "http://localhost:4000/auth/basic"
|
63
|
+
request.auth.basic @username, @password
|
64
|
+
|
65
|
+
response = HTTPI.get request, adapter
|
66
|
+
response.body.should_not include(@error_message)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
shared_examples_for "it works with HTTP digest auth" do
|
71
|
+
it "and access a secured page" do
|
72
|
+
request = HTTPI::Request.new :url => "http://localhost:4000/auth/digest"
|
73
|
+
request.auth.digest @username, @password
|
74
|
+
|
75
|
+
response = HTTPI.get request, adapter
|
76
|
+
response.body.should_not include(@error_message)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
HTTPI::Adapter::ADAPTERS.keys.each do |adapter|
|
81
|
+
context "using :#{adapter}" do
|
82
|
+
let(:adapter) { adapter }
|
83
|
+
it_should_behave_like "an HTTP client"
|
84
|
+
it_should_behave_like "it works with HTTP basic auth"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
(HTTPI::Adapter::ADAPTERS.keys - [:net_http]).each do |adapter|
|
89
|
+
context "using :#{adapter}" do
|
90
|
+
let(:adapter) { adapter }
|
91
|
+
it_should_behave_like "it works with HTTP digest auth"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "mock_server"
|
3
|
+
|
4
|
+
IntegrationServer = Rack::Builder.new do
|
5
|
+
map "/" do
|
6
|
+
run lambda {|env|
|
7
|
+
case env["REQUEST_METHOD"]
|
8
|
+
when "HEAD" then
|
9
|
+
[200, {"Content-Type" => "text/plain", "Content-Length" => "5"}, []]
|
10
|
+
when "GET", "POST" then
|
11
|
+
[200, {"Content-Type" => "text/plain", "Content-Length" => "5"}, ["Hello"]]
|
12
|
+
when "PUT", "DELETE"
|
13
|
+
body = "#{env["REQUEST_METHOD"]} is not allowed"
|
14
|
+
[200, {"Content-Type" => "text/plain", "Content-Length" => body.size.to_s}, [body]]
|
15
|
+
end
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
map "/x-header" do
|
20
|
+
run lambda {|env|
|
21
|
+
body = "X-Header is #{env["HTTP_X_HEADER"]}"
|
22
|
+
[200, {"Content-Type" => "text/plain", "Content-Length" => body.size.to_s}, [body]]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
map "/auth" do
|
27
|
+
map "/basic" do
|
28
|
+
run Rack::Auth::Basic do |user, password|
|
29
|
+
user == "admin" && password == "secret"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
map "/digest" do
|
34
|
+
run Rack::Auth::Digest::MD5 do |username|
|
35
|
+
{"admin" => "pwd"}[username]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Fixture
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def xml
|
5
|
+
@xml ||= load :xml
|
6
|
+
end
|
7
|
+
|
8
|
+
def xml_dime
|
9
|
+
@xml_dime ||= load :xml_dime
|
10
|
+
end
|
11
|
+
|
12
|
+
def gzip
|
13
|
+
@gzip ||= load :xml, :gz
|
14
|
+
end
|
15
|
+
|
16
|
+
def dime
|
17
|
+
@dime ||= load :xml_dime, :dime
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def load(fixture, type = :xml)
|
23
|
+
File.read File.expand_path("../../fixtures/#{fixture}.#{type}", __FILE__)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
RSpec::Matchers.define :match_response do |options|
|
2
|
+
defaults = { :code => 200, :headers => { "Accept-encoding" => "utf-8" }, :body => "" }
|
3
|
+
response = defaults.merge options
|
4
|
+
|
5
|
+
match do |actual|
|
6
|
+
actual.should be_an(HTTPI::Response)
|
7
|
+
actual.code.should == response[:code]
|
8
|
+
downcase(actual.headers).should == downcase(response[:headers])
|
9
|
+
actual.body.should == response[:body]
|
10
|
+
end
|
11
|
+
|
12
|
+
def downcase(hash)
|
13
|
+
hash.inject({}) do |memo, (key, value)|
|
14
|
+
memo[key.downcase] = value.downcase
|
15
|
+
memo
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cs-httpi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.5.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Celestino Gomes
|
9
|
+
- Renato Elias
|
10
|
+
- Lenon Marcel
|
11
|
+
- Madson Cardoso
|
12
|
+
- Luca Bastos
|
13
|
+
- Marcelo Linhares
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
date: 2011-07-01 00:00:00.000000000Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: rack
|
21
|
+
requirement: &19657920 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
type: :runtime
|
28
|
+
prerelease: false
|
29
|
+
version_requirements: *19657920
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: &19657500 !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: *19657500
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: autotest
|
43
|
+
requirement: &19657080 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: *19657080
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: mocha
|
54
|
+
requirement: &19656660 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *19656660
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: webmock
|
65
|
+
requirement: &19656240 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: *19656240
|
74
|
+
description: HTTPI provides a common interface for Ruby HTTP libraries. This gem is
|
75
|
+
a fork of httpi gem (https://github.com/rubiii/httpi)
|
76
|
+
email:
|
77
|
+
- tinorj@gmail.com
|
78
|
+
- renato.elias@gmail.com
|
79
|
+
- lenon.marcel@gmail.com
|
80
|
+
- madsonmac@gmail.com
|
81
|
+
- lucabastos@gmail.com
|
82
|
+
- marcelolinhares@gmail.com
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .autotest
|
88
|
+
- .gitignore
|
89
|
+
- .rspec
|
90
|
+
- .travis.yml
|
91
|
+
- CHANGELOG.md
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- autotest/discover.rb
|
97
|
+
- cs-httpi.gemspec
|
98
|
+
- lib/cs-httpi.rb
|
99
|
+
- lib/cs-httpi/adapter.rb
|
100
|
+
- lib/cs-httpi/adapter/curb.rb
|
101
|
+
- lib/cs-httpi/adapter/httpclient.rb
|
102
|
+
- lib/cs-httpi/adapter/net_http.rb
|
103
|
+
- lib/cs-httpi/auth/config.rb
|
104
|
+
- lib/cs-httpi/auth/ssl.rb
|
105
|
+
- lib/cs-httpi/dime.rb
|
106
|
+
- lib/cs-httpi/request.rb
|
107
|
+
- lib/cs-httpi/response.rb
|
108
|
+
- lib/cs-httpi/version.rb
|
109
|
+
- nbproject/private/private.properties
|
110
|
+
- nbproject/private/rake-d.txt
|
111
|
+
- nbproject/project.properties
|
112
|
+
- nbproject/project.xml
|
113
|
+
- spec/cs-httpi/adapter/curb_spec.rb
|
114
|
+
- spec/cs-httpi/adapter/httpclient_spec.rb
|
115
|
+
- spec/cs-httpi/adapter/net_http_spec.rb
|
116
|
+
- spec/cs-httpi/adapter_spec.rb
|
117
|
+
- spec/cs-httpi/auth/config_spec.rb
|
118
|
+
- spec/cs-httpi/auth/ssl_spec.rb
|
119
|
+
- spec/cs-httpi/httpi_spec.rb
|
120
|
+
- spec/cs-httpi/request_spec.rb
|
121
|
+
- spec/cs-httpi/response_spec.rb
|
122
|
+
- spec/fixtures/attachment.gif
|
123
|
+
- spec/fixtures/client_cert.pem
|
124
|
+
- spec/fixtures/client_key.pem
|
125
|
+
- spec/fixtures/xml.gz
|
126
|
+
- spec/fixtures/xml.xml
|
127
|
+
- spec/fixtures/xml_dime.dime
|
128
|
+
- spec/fixtures/xml_dime.xml
|
129
|
+
- spec/integration/request_spec.rb
|
130
|
+
- spec/integration/server.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
- spec/support/fixture.rb
|
133
|
+
- spec/support/matchers.rb
|
134
|
+
homepage: http://github.com/concretesolutions/cs-httpi
|
135
|
+
licenses: []
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project: cs-httpi
|
154
|
+
rubygems_version: 1.8.1
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: Interface for Ruby HTTP libraries
|
158
|
+
test_files: []
|