esank-rest-client 1.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +285 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/bin/restclient +93 -0
- data/history.md +134 -0
- data/lib/rest-client.rb +2 -0
- data/lib/rest_client.rb +2 -0
- data/lib/restclient.rb +174 -0
- data/lib/restclient/abstract_response.rb +107 -0
- data/lib/restclient/exceptions.rb +193 -0
- data/lib/restclient/net_http_ext.rb +55 -0
- data/lib/restclient/payload.rb +235 -0
- data/lib/restclient/raw_response.rb +34 -0
- data/lib/restclient/request.rb +320 -0
- data/lib/restclient/resource.rb +169 -0
- data/lib/restclient/response.rb +24 -0
- data/spec/abstract_response_spec.rb +85 -0
- data/spec/base.rb +16 -0
- data/spec/exceptions_spec.rb +98 -0
- 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/master_shake.jpg +0 -0
- data/spec/payload_spec.rb +234 -0
- data/spec/raw_response_spec.rb +17 -0
- data/spec/request2_spec.rb +40 -0
- data/spec/request_spec.rb +554 -0
- data/spec/resource_spec.rb +134 -0
- data/spec/response_spec.rb +169 -0
- data/spec/restclient_spec.rb +73 -0
- metadata +164 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
require 'webmock/rspec'
|
4
|
+
include WebMock
|
5
|
+
|
6
|
+
describe RestClient::Resource do
|
7
|
+
before do
|
8
|
+
@resource = RestClient::Resource.new('http://some/resource', :user => 'jane', :password => 'mypass', :headers => {'X-Something' => '1'})
|
9
|
+
end
|
10
|
+
|
11
|
+
context "Resource delegation" do
|
12
|
+
it "GET" do
|
13
|
+
RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
14
|
+
@resource.get
|
15
|
+
end
|
16
|
+
|
17
|
+
it "HEAD" do
|
18
|
+
RestClient::Request.should_receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
19
|
+
@resource.head
|
20
|
+
end
|
21
|
+
|
22
|
+
it "POST" do
|
23
|
+
RestClient::Request.should_receive(:execute).with(:method => :post, :url => 'http://some/resource', :payload => 'abc', :headers => {:content_type => 'image/jpg', 'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
24
|
+
@resource.post 'abc', :content_type => 'image/jpg'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "PUT" do
|
28
|
+
RestClient::Request.should_receive(:execute).with(:method => :put, :url => 'http://some/resource', :payload => 'abc', :headers => {:content_type => 'image/jpg', 'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
29
|
+
@resource.put 'abc', :content_type => 'image/jpg'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "PATCH" do
|
33
|
+
RestClient::Request.should_receive(:execute).with(:method => :patch, :url => 'http://some/resource', :payload => 'abc', :headers => {:content_type => 'image/jpg', 'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
34
|
+
@resource.patch 'abc', :content_type => 'image/jpg'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "DELETE" do
|
38
|
+
RestClient::Request.should_receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
39
|
+
@resource.delete
|
40
|
+
end
|
41
|
+
|
42
|
+
it "overrides resource headers" do
|
43
|
+
RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {'X-Something' => '2'}, :user => 'jane', :password => 'mypass')
|
44
|
+
@resource.get 'X-Something' => '2'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "can instantiate with no user/password" do
|
49
|
+
@resource = RestClient::Resource.new('http://some/resource')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is backwards compatible with previous constructor" do
|
53
|
+
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
54
|
+
@resource.user.should == 'user'
|
55
|
+
@resource.password.should == 'pass'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "concatenates urls, inserting a slash when it needs one" do
|
59
|
+
@resource.concat_urls('http://example.com', 'resource').should == 'http://example.com/resource'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "concatenates urls, using no slash if the first url ends with a slash" do
|
63
|
+
@resource.concat_urls('http://example.com/', 'resource').should == 'http://example.com/resource'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "concatenates urls, using no slash if the second url starts with a slash" do
|
67
|
+
@resource.concat_urls('http://example.com', '/resource').should == 'http://example.com/resource'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "concatenates even non-string urls, :posts + 1 => 'posts/1'" do
|
71
|
+
@resource.concat_urls(:posts, 1).should == 'posts/1'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "offers subresources via []" do
|
75
|
+
parent = RestClient::Resource.new('http://example.com')
|
76
|
+
parent['posts'].url.should == 'http://example.com/posts'
|
77
|
+
end
|
78
|
+
|
79
|
+
it "transports options to subresources" do
|
80
|
+
parent = RestClient::Resource.new('http://example.com', :user => 'user', :password => 'password')
|
81
|
+
parent['posts'].user.should == 'user'
|
82
|
+
parent['posts'].password.should == 'password'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "passes a given block to subresources" do
|
86
|
+
block = Proc.new{|r| r}
|
87
|
+
parent = RestClient::Resource.new('http://example.com', &block)
|
88
|
+
parent['posts'].block.should == block
|
89
|
+
end
|
90
|
+
|
91
|
+
it "the block should be overrideable" do
|
92
|
+
block1 = Proc.new{|r| r}
|
93
|
+
block2 = Proc.new{|r| r}
|
94
|
+
parent = RestClient::Resource.new('http://example.com', &block1)
|
95
|
+
# parent['posts', &block2].block.should == block2 # ruby 1.9 syntax
|
96
|
+
parent.send(:[], 'posts', &block2).block.should == block2
|
97
|
+
end
|
98
|
+
|
99
|
+
it "the block should be overrideable in ruby 1.9 syntax" do
|
100
|
+
block = Proc.new{|r| r}
|
101
|
+
parent = RestClient::Resource.new('http://example.com', &block)
|
102
|
+
r19_syntax = %q{
|
103
|
+
parent['posts', &->(r){r}].block.should_not == block
|
104
|
+
}
|
105
|
+
if is_ruby_19?
|
106
|
+
eval(r19_syntax)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "prints its url with to_s" do
|
111
|
+
RestClient::Resource.new('x').to_s.should == 'x'
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'block' do
|
115
|
+
it 'can use block when creating the resource' do
|
116
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
117
|
+
resource = RestClient::Resource.new('www.example.com') { |response, request| 'foo' }
|
118
|
+
resource.get.should == 'foo'
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'can use block when executing the resource' do
|
122
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
123
|
+
resource = RestClient::Resource.new('www.example.com')
|
124
|
+
resource.get { |response, request| 'foo' }.should == 'foo'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'execution block override resource block' do
|
128
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
129
|
+
resource = RestClient::Resource.new('www.example.com') { |response, request| 'foo' }
|
130
|
+
resource.get { |response, request| 'bar' }.should == 'bar'
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
require 'webmock/rspec'
|
4
|
+
include WebMock
|
5
|
+
|
6
|
+
describe RestClient::Response do
|
7
|
+
before do
|
8
|
+
@net_http_res = mock('net http response', :to_hash => {"Status" => ["200 OK"]}, :code => 200)
|
9
|
+
@request = mock('http request', :user => nil, :password => nil)
|
10
|
+
@response = RestClient::Response.create('abc', @net_http_res, {})
|
11
|
+
end
|
12
|
+
|
13
|
+
it "behaves like string" do
|
14
|
+
@response.should.to_s == 'abc'
|
15
|
+
@response.to_str.should == 'abc'
|
16
|
+
@response.to_i.should == 200
|
17
|
+
end
|
18
|
+
|
19
|
+
it "accepts nil strings and sets it to empty for the case of HEAD" do
|
20
|
+
RestClient::Response.create(nil, @net_http_res, {}).should.to_s == ""
|
21
|
+
end
|
22
|
+
|
23
|
+
it "test headers and raw headers" do
|
24
|
+
@response.raw_headers["Status"][0].should == "200 OK"
|
25
|
+
@response.headers[:status].should == "200 OK"
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "cookie processing" do
|
29
|
+
it "should correctly deal with one Set-Cookie header with one cookie inside" do
|
30
|
+
net_http_res = mock('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT"]})
|
31
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
32
|
+
response.headers[:set_cookie].should == ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT"]
|
33
|
+
response.cookies.should == { "main_page" => "main_page_no_rewrite" }
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should correctly deal with multiple cookies [multiple Set-Cookie headers]" do
|
37
|
+
net_http_res = mock('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT", "remember_me=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT", "user=somebody; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"]})
|
38
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
39
|
+
response.headers[:set_cookie].should == ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT", "remember_me=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT", "user=somebody; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"]
|
40
|
+
response.cookies.should == {
|
41
|
+
"main_page" => "main_page_no_rewrite",
|
42
|
+
"remember_me" => "",
|
43
|
+
"user" => "somebody"
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should correctly deal with multiple cookies [one Set-Cookie header with multiple cookies]" do
|
48
|
+
net_http_res = mock('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT, remember_me=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT, user=somebody; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"]})
|
49
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
50
|
+
response.cookies.should == {
|
51
|
+
"main_page" => "main_page_no_rewrite",
|
52
|
+
"remember_me" => "",
|
53
|
+
"user" => "somebody"
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "exceptions processing" do
|
59
|
+
it "should return itself for normal codes" do
|
60
|
+
(200..206).each do |code|
|
61
|
+
net_http_res = mock('net http response', :code => '200')
|
62
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
63
|
+
response.return! @request
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should throw an exception for other codes" do
|
68
|
+
RestClient::Exceptions::EXCEPTIONS_MAP.each_key do |code|
|
69
|
+
unless (200..207).include? code
|
70
|
+
net_http_res = mock('net http response', :code => code.to_i)
|
71
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
72
|
+
lambda { response.return!}.should raise_error
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "redirection" do
|
80
|
+
|
81
|
+
it "follows a redirection when the request is a get" do
|
82
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
83
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
84
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should == 'Foo'
|
85
|
+
end
|
86
|
+
|
87
|
+
it "follows a redirection and keep the parameters" do
|
88
|
+
stub_request(:get, 'http://foo:bar@some/resource').with(:headers => {'Accept' => 'application/json'}).to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
89
|
+
stub_request(:get, 'http://foo:bar@new/resource').with(:headers => {'Accept' => 'application/json'}).to_return(:body => 'Foo')
|
90
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :user => 'foo', :password => 'bar', :headers => {:accept => :json}).body.should == 'Foo'
|
91
|
+
end
|
92
|
+
|
93
|
+
it "follows a redirection and keep the cookies" do
|
94
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Set-Cookie' => CGI::Cookie.new('Foo', 'Bar'), 'Location' => 'http://new/resource', })
|
95
|
+
stub_request(:get, 'http://new/resource').with(:headers => {'Cookie' => 'Foo=Bar'}).to_return(:body => 'Qux')
|
96
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should == 'Qux'
|
97
|
+
end
|
98
|
+
|
99
|
+
it "doesn't follow a 301 when the request is a post" do
|
100
|
+
net_http_res = mock('net http response', :code => 301)
|
101
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|
102
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::MovedPermanently)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "doesn't follow a 302 when the request is a post" do
|
106
|
+
net_http_res = mock('net http response', :code => 302)
|
107
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|
108
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::Found)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "doesn't follow a 307 when the request is a post" do
|
112
|
+
net_http_res = mock('net http response', :code => 307)
|
113
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|
114
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::TemporaryRedirect)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "doesn't follow a redirection when the request is a put" do
|
118
|
+
net_http_res = mock('net http response', :code => 301)
|
119
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :put})
|
120
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::MovedPermanently)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "follows a redirection when the request is a post and result is a 303" do
|
124
|
+
stub_request(:put, 'http://some/resource').to_return(:body => '', :status => 303, :headers => {'Location' => 'http://new/resource'})
|
125
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
126
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :put).body.should == 'Foo'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "follows a redirection when the request is a head" do
|
130
|
+
stub_request(:head, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
131
|
+
stub_request(:head, 'http://new/resource').to_return(:body => 'Foo')
|
132
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :head).body.should == 'Foo'
|
133
|
+
end
|
134
|
+
|
135
|
+
it "handles redirects with relative paths" do
|
136
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'index'})
|
137
|
+
stub_request(:get, 'http://some/index').to_return(:body => 'Foo')
|
138
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should == 'Foo'
|
139
|
+
end
|
140
|
+
|
141
|
+
it "handles redirects with relative path and query string" do
|
142
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'index?q=1'})
|
143
|
+
stub_request(:get, 'http://some/index?q=1').to_return(:body => 'Foo')
|
144
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should == 'Foo'
|
145
|
+
end
|
146
|
+
|
147
|
+
it "follow a redirection when the request is a get and the response is in the 30x range" do
|
148
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
149
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
150
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should == 'Foo'
|
151
|
+
end
|
152
|
+
|
153
|
+
it "follows no more than 10 redirections before raising error" do
|
154
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
155
|
+
stub_request(:get, 'http://some/redirect-2').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
156
|
+
lambda { RestClient::Request.execute(:url => 'http://some/redirect-1', :method => :get) }.should raise_error(RestClient::MaxRedirectsReached)
|
157
|
+
WebMock.should have_requested(:get, 'http://some/redirect-2').times(10)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "follows no more than max_redirects redirections, if specified" do
|
161
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
162
|
+
stub_request(:get, 'http://some/redirect-2').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
163
|
+
lambda { RestClient::Request.execute(:url => 'http://some/redirect-1', :method => :get, :max_redirects => 5) }.should raise_error(RestClient::MaxRedirectsReached)
|
164
|
+
WebMock.should have_requested(:get, 'http://some/redirect-2').times(5)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.join( File.dirname(File.expand_path(__FILE__)), 'base')
|
2
|
+
|
3
|
+
describe RestClient do
|
4
|
+
describe "API" do
|
5
|
+
it "GET" do
|
6
|
+
RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {})
|
7
|
+
RestClient.get('http://some/resource')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "POST" do
|
11
|
+
RestClient::Request.should_receive(:execute).with(:method => :post, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
12
|
+
RestClient.post('http://some/resource', 'payload')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "PUT" do
|
16
|
+
RestClient::Request.should_receive(:execute).with(:method => :put, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
17
|
+
RestClient.put('http://some/resource', 'payload')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "PATCH" do
|
21
|
+
RestClient::Request.should_receive(:execute).with(:method => :patch, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
22
|
+
RestClient.patch('http://some/resource', 'payload')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "DELETE" do
|
26
|
+
RestClient::Request.should_receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {})
|
27
|
+
RestClient.delete('http://some/resource')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "HEAD" do
|
31
|
+
RestClient::Request.should_receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {})
|
32
|
+
RestClient.head('http://some/resource')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "OPTIONS" do
|
36
|
+
RestClient::Request.should_receive(:execute).with(:method => :options, :url => 'http://some/resource', :headers => {})
|
37
|
+
RestClient.options('http://some/resource')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "logging" do
|
42
|
+
after do
|
43
|
+
RestClient.log = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "uses << if the log is not a string" do
|
47
|
+
log = RestClient.log = []
|
48
|
+
log.should_receive(:<<).with('xyz')
|
49
|
+
RestClient.log << 'xyz'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "displays the log to stdout" do
|
53
|
+
RestClient.log = 'stdout'
|
54
|
+
STDOUT.should_receive(:puts).with('xyz')
|
55
|
+
RestClient.log << 'xyz'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "displays the log to stderr" do
|
59
|
+
RestClient.log = 'stderr'
|
60
|
+
STDERR.should_receive(:puts).with('xyz')
|
61
|
+
RestClient.log << 'xyz'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "append the log to the requested filename" do
|
65
|
+
RestClient.log = '/tmp/restclient.log'
|
66
|
+
f = mock('file handle')
|
67
|
+
File.should_receive(:open).with('/tmp/restclient.log', 'a').and_yield(f)
|
68
|
+
f.should_receive(:puts).with('xyz')
|
69
|
+
RestClient.log << 'xyz'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: esank-rest-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 6
|
8
|
+
- 7
|
9
|
+
version: 1.6.7
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Adam Wiggins
|
13
|
+
- Julien Kirch
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-24 00:00:00 +05:30
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: mime-types
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 16
|
32
|
+
version: "1.16"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: webmock
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 9
|
46
|
+
- 1
|
47
|
+
version: 0.9.1
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: netrc
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
description: "A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete."
|
77
|
+
email: rest.client@librelist.com
|
78
|
+
executables:
|
79
|
+
- restclient
|
80
|
+
extensions: []
|
81
|
+
|
82
|
+
extra_rdoc_files:
|
83
|
+
- README.rdoc
|
84
|
+
- history.md
|
85
|
+
files:
|
86
|
+
- README.rdoc
|
87
|
+
- Rakefile
|
88
|
+
- VERSION
|
89
|
+
- bin/restclient
|
90
|
+
- lib/rest-client.rb
|
91
|
+
- lib/rest_client.rb
|
92
|
+
- lib/restclient.rb
|
93
|
+
- lib/restclient/abstract_response.rb
|
94
|
+
- lib/restclient/exceptions.rb
|
95
|
+
- lib/restclient/net_http_ext.rb
|
96
|
+
- lib/restclient/payload.rb
|
97
|
+
- lib/restclient/raw_response.rb
|
98
|
+
- lib/restclient/request.rb
|
99
|
+
- lib/restclient/resource.rb
|
100
|
+
- lib/restclient/response.rb
|
101
|
+
- spec/abstract_response_spec.rb
|
102
|
+
- spec/base.rb
|
103
|
+
- spec/exceptions_spec.rb
|
104
|
+
- spec/integration/certs/equifax.crt
|
105
|
+
- spec/integration/certs/verisign.crt
|
106
|
+
- spec/integration/request_spec.rb
|
107
|
+
- spec/integration_spec.rb
|
108
|
+
- spec/master_shake.jpg
|
109
|
+
- spec/payload_spec.rb
|
110
|
+
- spec/raw_response_spec.rb
|
111
|
+
- spec/request2_spec.rb
|
112
|
+
- spec/request_spec.rb
|
113
|
+
- spec/resource_spec.rb
|
114
|
+
- spec/response_spec.rb
|
115
|
+
- spec/restclient_spec.rb
|
116
|
+
- history.md
|
117
|
+
has_rdoc: true
|
118
|
+
homepage: http://github.com/archiloque/rest-client
|
119
|
+
licenses: []
|
120
|
+
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
requirements: []
|
143
|
+
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 1.3.7
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.
|
149
|
+
test_files:
|
150
|
+
- spec/abstract_response_spec.rb
|
151
|
+
- spec/base.rb
|
152
|
+
- spec/exceptions_spec.rb
|
153
|
+
- spec/integration/certs/equifax.crt
|
154
|
+
- spec/integration/certs/verisign.crt
|
155
|
+
- spec/integration/request_spec.rb
|
156
|
+
- spec/integration_spec.rb
|
157
|
+
- spec/master_shake.jpg
|
158
|
+
- spec/payload_spec.rb
|
159
|
+
- spec/raw_response_spec.rb
|
160
|
+
- spec/request2_spec.rb
|
161
|
+
- spec/request_spec.rb
|
162
|
+
- spec/resource_spec.rb
|
163
|
+
- spec/response_spec.rb
|
164
|
+
- spec/restclient_spec.rb
|