rest-client 1.1.0 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rest-client might be problematic. Click here for more details.
- data/README.rdoc +190 -13
- data/Rakefile +35 -26
- data/VERSION +1 -1
- data/bin/restclient +43 -38
- data/history.md +112 -0
- data/lib/rest-client.rb +2 -0
- data/lib/restclient.rb +107 -40
- data/lib/restclient/abstract_response.rb +106 -0
- data/lib/restclient/exceptions.rb +187 -82
- data/lib/restclient/net_http_ext.rb +11 -11
- data/lib/restclient/payload.rb +217 -168
- data/lib/restclient/raw_response.rb +28 -24
- data/lib/restclient/request.rb +310 -248
- data/lib/restclient/resource.rb +155 -132
- data/lib/restclient/response.rb +19 -15
- data/spec/abstract_response_spec.rb +85 -0
- data/spec/base.rb +6 -0
- data/spec/exceptions_spec.rb +79 -46
- data/spec/integration/certs/equifax.crt +19 -0
- data/spec/integration/certs/verisign.crt +14 -0
- data/spec/integration/request_spec.rb +25 -0
- data/spec/integration_spec.rb +38 -0
- data/spec/payload_spec.rb +187 -99
- data/spec/raw_response_spec.rb +12 -12
- data/spec/request2_spec.rb +27 -0
- data/spec/request_spec.rb +526 -494
- data/spec/resource_spec.rb +131 -72
- data/spec/response_spec.rb +166 -18
- data/spec/restclient_spec.rb +70 -50
- metadata +79 -20
- data/lib/restclient/mixin/response.rb +0 -48
- data/spec/mixin/response_spec.rb +0 -46
@@ -0,0 +1,19 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV
|
3
|
+
UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy
|
4
|
+
dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1
|
5
|
+
MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx
|
6
|
+
dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B
|
7
|
+
AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f
|
8
|
+
BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A
|
9
|
+
cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC
|
10
|
+
AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ
|
11
|
+
MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm
|
12
|
+
aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw
|
13
|
+
ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj
|
14
|
+
IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF
|
15
|
+
MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA
|
16
|
+
A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
|
17
|
+
7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh
|
18
|
+
1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
|
19
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,14 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG
|
3
|
+
A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz
|
4
|
+
cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2
|
5
|
+
MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV
|
6
|
+
BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt
|
7
|
+
YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN
|
8
|
+
ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE
|
9
|
+
BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is
|
10
|
+
I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G
|
11
|
+
CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do
|
12
|
+
lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc
|
13
|
+
AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k
|
14
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), '../base')
|
2
|
+
|
3
|
+
describe RestClient::Request do
|
4
|
+
describe "ssl verification" do
|
5
|
+
it "is successful with the correct ca_file" do
|
6
|
+
request = RestClient::Request.new(
|
7
|
+
:method => :get,
|
8
|
+
:url => 'https://www.google.com',
|
9
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
10
|
+
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "verisign.crt")
|
11
|
+
)
|
12
|
+
expect { request.execute }.to_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "is unsuccessful with an incorrect ca_file" do
|
16
|
+
request = RestClient::Request.new(
|
17
|
+
:method => :get,
|
18
|
+
:url => 'https://www.google.com',
|
19
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
20
|
+
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "equifax.crt")
|
21
|
+
)
|
22
|
+
expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
require 'webmock/rspec'
|
4
|
+
include WebMock
|
5
|
+
|
6
|
+
describe RestClient do
|
7
|
+
|
8
|
+
it "a simple request" do
|
9
|
+
body = 'abc'
|
10
|
+
stub_request(:get, "www.example.com").to_return(:body => body, :status => 200)
|
11
|
+
response = RestClient.get "www.example.com"
|
12
|
+
response.code.should == 200
|
13
|
+
response.body.should == body
|
14
|
+
end
|
15
|
+
|
16
|
+
it "a simple request with gzipped content" do
|
17
|
+
stub_request(:get, "www.example.com").with(:headers => { 'Accept-Encoding' => 'gzip, deflate' }).to_return(:body => "\037\213\b\b\006'\252H\000\003t\000\313T\317UH\257\312,HM\341\002\000G\242(\r\v\000\000\000", :status => 200, :headers => { 'Content-Encoding' => 'gzip' } )
|
18
|
+
response = RestClient.get "www.example.com"
|
19
|
+
response.code.should == 200
|
20
|
+
response.body.should == "i'm gziped\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "a 404" do
|
24
|
+
body = "Ho hai ! I'm not here !"
|
25
|
+
stub_request(:get, "www.example.com").to_return(:body => body, :status => 404)
|
26
|
+
begin
|
27
|
+
RestClient.get "www.example.com"
|
28
|
+
raise
|
29
|
+
rescue RestClient::ResourceNotFound => e
|
30
|
+
e.http_code.should == 404
|
31
|
+
e.response.code.should == 404
|
32
|
+
e.response.body.should == body
|
33
|
+
e.http_body.should == body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
data/spec/payload_spec.rb
CHANGED
@@ -1,131 +1,219 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
2
|
|
3
3
|
describe RestClient::Payload do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
4
|
+
context "A regular Payload" do
|
5
|
+
it "should use standard enctype as default content-type" do
|
6
|
+
RestClient::Payload::UrlEncoded.new({}).headers['Content-Type'].
|
7
|
+
should == 'application/x-www-form-urlencoded'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should form properly encoded params" do
|
11
|
+
RestClient::Payload::UrlEncoded.new({:foo => 'bar'}).to_s.
|
12
|
+
should == "foo=bar"
|
13
|
+
["foo=bar&baz=qux", "baz=qux&foo=bar"].should include(
|
14
|
+
RestClient::Payload::UrlEncoded.new({:foo => 'bar', :baz => 'qux'}).to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should escape parameters" do
|
18
|
+
RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'}).to_s.
|
19
|
+
should == "foo%20=bar"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should properly handle hashes as parameter" do
|
23
|
+
RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz' }}).to_s.
|
24
|
+
should == "foo[bar]=baz"
|
25
|
+
RestClient::Payload::UrlEncoded.new({:foo => {:bar => {:baz => 'qux' }}}).to_s.
|
26
|
+
should == "foo[bar][baz]=qux"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should handle many attributes inside a hash" do
|
30
|
+
parameters = RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz', :baz => 'qux'}}).to_s
|
31
|
+
parameters.should include("foo[bar]=baz", "foo[baz]=qux")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should handle attributes inside a an array inside an hash" do
|
35
|
+
parameters = RestClient::Payload::UrlEncoded.new({"foo" => [{"bar" => 'baz'}, {"bar" => 'qux'}]}).to_s
|
36
|
+
parameters.should include("foo[bar]=baz", "foo[bar]=qux")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should handle attributes inside a an array inside an array inside an hash" do
|
40
|
+
parameters = RestClient::Payload::UrlEncoded.new({"foo" => [ [{"bar" => 'baz'}, {"bar" => 'qux'}]]}).to_s
|
41
|
+
parameters.should include("foo[bar]=baz", "foo[bar]=qux")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should form properly use symbols as parameters" do
|
45
|
+
RestClient::Payload::UrlEncoded.new({:foo => :bar}).to_s.
|
46
|
+
should == "foo=bar"
|
47
|
+
RestClient::Payload::UrlEncoded.new({:foo => {:bar => :baz }}).to_s.
|
48
|
+
should == "foo[bar]=baz"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should properly handle arrays as repeated parameters" do
|
52
|
+
RestClient::Payload::UrlEncoded.new({:foo => ['bar']}).to_s.
|
53
|
+
should == "foo[]=bar"
|
54
|
+
RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s.
|
55
|
+
should == "foo[]=bar&foo[]=baz"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
context "A multipart Payload" do
|
61
|
+
it "should use standard enctype as default content-type" do
|
62
|
+
m = RestClient::Payload::Multipart.new({})
|
63
|
+
m.stub!(:boundary).and_return(123)
|
64
|
+
m.headers['Content-Type'].should == 'multipart/form-data; boundary=123'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should form properly separated multipart data" do
|
68
|
+
m = RestClient::Payload::Multipart.new([[:bar, "baz"], [:foo, "bar"]])
|
69
|
+
m.to_s.should == <<-EOS
|
41
70
|
--#{m.boundary}\r
|
42
|
-
Content-Disposition:
|
71
|
+
Content-Disposition: form-data; name="bar"\r
|
43
72
|
\r
|
44
73
|
baz\r
|
45
74
|
--#{m.boundary}\r
|
46
|
-
Content-Disposition:
|
75
|
+
Content-Disposition: form-data; name="foo"\r
|
47
76
|
\r
|
48
77
|
bar\r
|
49
78
|
--#{m.boundary}--\r
|
50
|
-
EOS
|
51
|
-
|
79
|
+
EOS
|
80
|
+
end
|
52
81
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
m.to_s.should == <<-EOS
|
82
|
+
it "should not escape parameters names" do
|
83
|
+
m = RestClient::Payload::Multipart.new([["bar ", "baz"]])
|
84
|
+
m.to_s.should == <<-EOS
|
57
85
|
--#{m.boundary}\r
|
58
|
-
Content-Disposition:
|
86
|
+
Content-Disposition: form-data; name="bar "\r
|
87
|
+
\r
|
88
|
+
baz\r
|
89
|
+
--#{m.boundary}--\r
|
90
|
+
EOS
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should form properly separated multipart data" do
|
94
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
95
|
+
m = RestClient::Payload::Multipart.new({:foo => f})
|
96
|
+
m.to_s.should == <<-EOS
|
97
|
+
--#{m.boundary}\r
|
98
|
+
Content-Disposition: form-data; name="foo"; filename="master_shake.jpg"\r
|
99
|
+
Content-Type: image/jpeg\r
|
100
|
+
\r
|
101
|
+
#{IO.read(f.path)}\r
|
102
|
+
--#{m.boundary}--\r
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should ignore the name attribute when it's not set" do
|
107
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
108
|
+
m = RestClient::Payload::Multipart.new({nil => f})
|
109
|
+
m.to_s.should == <<-EOS
|
110
|
+
--#{m.boundary}\r
|
111
|
+
Content-Disposition: form-data; filename="master_shake.jpg"\r
|
59
112
|
Content-Type: image/jpeg\r
|
60
113
|
\r
|
61
114
|
#{IO.read(f.path)}\r
|
62
115
|
--#{m.boundary}--\r
|
63
|
-
EOS
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
116
|
+
EOS
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should detect optional (original) content type and filename" do
|
120
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
121
|
+
f.instance_eval "def content_type; 'text/plain'; end"
|
122
|
+
f.instance_eval "def original_filename; 'foo.txt'; end"
|
123
|
+
m = RestClient::Payload::Multipart.new({:foo => f})
|
124
|
+
m.to_s.should == <<-EOS
|
72
125
|
--#{m.boundary}\r
|
73
|
-
Content-Disposition:
|
126
|
+
Content-Disposition: form-data; name="foo"; filename="foo.txt"\r
|
74
127
|
Content-Type: text/plain\r
|
75
128
|
\r
|
76
129
|
#{IO.read(f.path)}\r
|
77
130
|
--#{m.boundary}--\r
|
78
|
-
EOS
|
79
|
-
|
131
|
+
EOS
|
132
|
+
end
|
80
133
|
|
81
|
-
|
82
|
-
|
83
|
-
|
134
|
+
it "should handle hash in hash parameters" do
|
135
|
+
m = RestClient::Payload::Multipart.new({:bar => {:baz => "foo"}})
|
136
|
+
m.to_s.should == <<-EOS
|
84
137
|
--#{m.boundary}\r
|
85
|
-
Content-Disposition:
|
138
|
+
Content-Disposition: form-data; name="bar[baz]"\r
|
86
139
|
\r
|
87
140
|
foo\r
|
88
141
|
--#{m.boundary}--\r
|
89
|
-
EOS
|
142
|
+
EOS
|
90
143
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
144
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
145
|
+
f.instance_eval "def content_type; 'text/plain'; end"
|
146
|
+
f.instance_eval "def original_filename; 'foo.txt'; end"
|
147
|
+
m = RestClient::Payload::Multipart.new({:foo => {:bar => f}})
|
148
|
+
m.to_s.should == <<-EOS
|
96
149
|
--#{m.boundary}\r
|
97
|
-
Content-Disposition:
|
150
|
+
Content-Disposition: form-data; name="foo[bar]"; filename="foo.txt"\r
|
98
151
|
Content-Type: text/plain\r
|
99
152
|
\r
|
100
153
|
#{IO.read(f.path)}\r
|
101
154
|
--#{m.boundary}--\r
|
102
|
-
EOS
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
155
|
+
EOS
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
context "streamed payloads" do
|
161
|
+
it "should properly determine the size of file payloads" do
|
162
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
163
|
+
payload = RestClient::Payload.generate(f)
|
164
|
+
payload.size.should == 22_545
|
165
|
+
payload.length.should == 22_545
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should properly determine the size of other kinds of streaming payloads" do
|
169
|
+
s = StringIO.new 'foo'
|
170
|
+
payload = RestClient::Payload.generate(s)
|
171
|
+
payload.size.should == 3
|
172
|
+
payload.length.should == 3
|
173
|
+
|
174
|
+
begin
|
175
|
+
f = Tempfile.new "rest-client"
|
176
|
+
f.write 'foo bar'
|
177
|
+
|
178
|
+
payload = RestClient::Payload.generate(f)
|
179
|
+
payload.size.should == 7
|
180
|
+
payload.length.should == 7
|
181
|
+
ensure
|
182
|
+
f.close
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context "Payload generation" do
|
188
|
+
it "should recognize standard urlencoded params" do
|
189
|
+
RestClient::Payload.generate({"foo" => 'bar'}).should be_kind_of(RestClient::Payload::UrlEncoded)
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should recognize multipart params" do
|
193
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
194
|
+
RestClient::Payload.generate({"foo" => f}).should be_kind_of(RestClient::Payload::Multipart)
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should be multipart if forced" do
|
198
|
+
RestClient::Payload.generate({"foo" => "bar", :multipart => true}).should be_kind_of(RestClient::Payload::Multipart)
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should return data if no of the above" do
|
202
|
+
RestClient::Payload.generate("data").should be_kind_of(RestClient::Payload::Base)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should recognize nested multipart payloads" do
|
206
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
207
|
+
RestClient::Payload.generate({"foo" => {"file" => f}}).should be_kind_of(RestClient::Payload::Multipart)
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should recognize file payloads that can be streamed" do
|
211
|
+
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
|
212
|
+
RestClient::Payload.generate(f).should be_kind_of(RestClient::Payload::Streamed)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should recognize other payloads that can be streamed" do
|
216
|
+
RestClient::Payload.generate(StringIO.new('foo')).should be_kind_of(RestClient::Payload::Streamed)
|
217
|
+
end
|
218
|
+
end
|
131
219
|
end
|
data/spec/raw_response_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require File.dirname(__FILE__)
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
2
|
|
3
3
|
describe RestClient::RawResponse do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
before do
|
5
|
+
@tf = mock("Tempfile", :read => "the answer is 42", :open => true)
|
6
|
+
@net_http_res = mock('net http response')
|
7
|
+
@response = RestClient::RawResponse.new(@tf, @net_http_res, {})
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it "behaves like string" do
|
11
|
+
@response.to_s.should == 'the answer is 42'
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
it "exposes a Tempfile" do
|
15
|
+
@response.file.should == @tf
|
16
|
+
end
|
17
17
|
end
|