rest-client-maestro 1.7.2.maestro
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/AUTHORS +69 -0
- data/Gemfile +7 -0
- data/README.rdoc +322 -0
- data/Rakefile +49 -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/abstract_response.rb +106 -0
- data/lib/restclient/exceptions.rb +198 -0
- data/lib/restclient/net_http_ext.rb +55 -0
- data/lib/restclient/payload.rb +242 -0
- data/lib/restclient/raw_response.rb +34 -0
- data/lib/restclient/request.rb +346 -0
- data/lib/restclient/resource.rb +169 -0
- data/lib/restclient/response.rb +26 -0
- data/lib/restclient.rb +174 -0
- data/rest-client-maestro.gemspec +23 -0
- data/spec/integration/capath_equifax/578d5c04.0 +19 -0
- data/spec/integration/capath_equifax/594f1775.0 +19 -0
- data/spec/integration/capath_equifax/README +8 -0
- data/spec/integration/capath_equifax/equifax.crt +19 -0
- data/spec/integration/capath_verisign/415660c1.0 +14 -0
- data/spec/integration/capath_verisign/7651b327.0 +14 -0
- data/spec/integration/capath_verisign/README +8 -0
- data/spec/integration/capath_verisign/verisign.crt +14 -0
- data/spec/integration/certs/equifax.crt +19 -0
- data/spec/integration/certs/verisign.crt +14 -0
- data/spec/integration/integration_spec.rb +35 -0
- data/spec/integration/request_spec.rb +63 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/unit/abstract_response_spec.rb +85 -0
- data/spec/unit/exceptions_spec.rb +95 -0
- data/spec/unit/master_shake.jpg +0 -0
- data/spec/unit/payload_spec.rb +245 -0
- data/spec/unit/raw_response_spec.rb +17 -0
- data/spec/unit/request2_spec.rb +32 -0
- data/spec/unit/request_spec.rb +621 -0
- data/spec/unit/resource_spec.rb +133 -0
- data/spec/unit/response_spec.rb +166 -0
- data/spec/unit/restclient_spec.rb +73 -0
- metadata +220 -0
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RestClient::Resource do
|
4
|
+
before do
|
5
|
+
@resource = RestClient::Resource.new('http://some/resource', :user => 'jane', :password => 'mypass', :headers => {'X-Something' => '1'})
|
6
|
+
end
|
7
|
+
|
8
|
+
context "Resource delegation" do
|
9
|
+
it "GET" do
|
10
|
+
RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
11
|
+
@resource.get
|
12
|
+
end
|
13
|
+
|
14
|
+
it "HEAD" do
|
15
|
+
RestClient::Request.should_receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
16
|
+
@resource.head
|
17
|
+
end
|
18
|
+
|
19
|
+
it "POST" do
|
20
|
+
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')
|
21
|
+
@resource.post 'abc', :content_type => 'image/jpg'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "PUT" do
|
25
|
+
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')
|
26
|
+
@resource.put 'abc', :content_type => 'image/jpg'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "PATCH" do
|
30
|
+
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')
|
31
|
+
@resource.patch 'abc', :content_type => 'image/jpg'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "DELETE" do
|
35
|
+
RestClient::Request.should_receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
36
|
+
@resource.delete
|
37
|
+
end
|
38
|
+
|
39
|
+
it "overrides resource headers" do
|
40
|
+
RestClient::Request.should_receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {'X-Something' => '2'}, :user => 'jane', :password => 'mypass')
|
41
|
+
@resource.get 'X-Something' => '2'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can instantiate with no user/password" do
|
46
|
+
@resource = RestClient::Resource.new('http://some/resource')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "is backwards compatible with previous constructor" do
|
50
|
+
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
51
|
+
@resource.user.should eq 'user'
|
52
|
+
@resource.password.should eq 'pass'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "concatenates urls, inserting a slash when it needs one" do
|
56
|
+
@resource.concat_urls('http://example.com', 'resource').should eq 'http://example.com/resource'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "concatenates urls, using no slash if the first url ends with a slash" do
|
60
|
+
@resource.concat_urls('http://example.com/', 'resource').should eq 'http://example.com/resource'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "concatenates urls, using no slash if the second url starts with a slash" do
|
64
|
+
@resource.concat_urls('http://example.com', '/resource').should eq 'http://example.com/resource'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "concatenates even non-string urls, :posts + 1 => 'posts/1'" do
|
68
|
+
@resource.concat_urls(:posts, 1).should eq 'posts/1'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "offers subresources via []" do
|
72
|
+
parent = RestClient::Resource.new('http://example.com')
|
73
|
+
parent['posts'].url.should eq 'http://example.com/posts'
|
74
|
+
end
|
75
|
+
|
76
|
+
it "transports options to subresources" do
|
77
|
+
parent = RestClient::Resource.new('http://example.com', :user => 'user', :password => 'password')
|
78
|
+
parent['posts'].user.should eq 'user'
|
79
|
+
parent['posts'].password.should eq 'password'
|
80
|
+
end
|
81
|
+
|
82
|
+
it "passes a given block to subresources" do
|
83
|
+
block = Proc.new{|r| r}
|
84
|
+
parent = RestClient::Resource.new('http://example.com', &block)
|
85
|
+
parent['posts'].block.should eq block
|
86
|
+
end
|
87
|
+
|
88
|
+
it "the block should be overrideable" do
|
89
|
+
block1 = Proc.new{|r| r}
|
90
|
+
block2 = Proc.new{|r| r}
|
91
|
+
parent = RestClient::Resource.new('http://example.com', &block1)
|
92
|
+
# parent['posts', &block2].block.should eq block2 # ruby 1.9 syntax
|
93
|
+
parent.send(:[], 'posts', &block2).block.should eq block2
|
94
|
+
end
|
95
|
+
|
96
|
+
it "the block should be overrideable in ruby 1.9 syntax" do
|
97
|
+
block = Proc.new{|r| r}
|
98
|
+
parent = RestClient::Resource.new('http://example.com', &block)
|
99
|
+
r19_syntax = %q{
|
100
|
+
parent['posts', &->(r){r}].block.should_not eq block
|
101
|
+
}
|
102
|
+
if is_ruby_19?
|
103
|
+
eval(r19_syntax)
|
104
|
+
else
|
105
|
+
parent.should_not be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "prints its url with to_s" do
|
110
|
+
RestClient::Resource.new('x').to_s.should eq 'x'
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'block' do
|
114
|
+
it 'can use block when creating the resource' do
|
115
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
116
|
+
resource = RestClient::Resource.new('www.example.com') { |response, request| 'foo' }
|
117
|
+
resource.get.should eq 'foo'
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'can use block when executing the resource' do
|
121
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
122
|
+
resource = RestClient::Resource.new('www.example.com')
|
123
|
+
resource.get { |response, request| 'foo' }.should eq 'foo'
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'execution block override resource block' do
|
127
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
128
|
+
resource = RestClient::Resource.new('www.example.com') { |response, request| 'foo' }
|
129
|
+
resource.get { |response, request| 'bar' }.should eq 'bar'
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RestClient::Response do
|
4
|
+
before do
|
5
|
+
@net_http_res = double('net http response', :to_hash => {"Status" => ["200 OK"]}, :code => 200)
|
6
|
+
@request = double('http request', :user => nil, :password => nil)
|
7
|
+
@response = RestClient::Response.create('abc', @net_http_res, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
it "behaves like string" do
|
11
|
+
@response.to_s.should eq 'abc'
|
12
|
+
@response.to_str.should eq 'abc'
|
13
|
+
@response.to_i.should eq 200
|
14
|
+
end
|
15
|
+
|
16
|
+
it "accepts nil strings and sets it to empty for the case of HEAD" do
|
17
|
+
RestClient::Response.create(nil, @net_http_res, {}).to_s.should eq ""
|
18
|
+
end
|
19
|
+
|
20
|
+
it "test headers and raw headers" do
|
21
|
+
@response.raw_headers["Status"][0].should eq "200 OK"
|
22
|
+
@response.headers[:status].should eq "200 OK"
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "cookie processing" do
|
26
|
+
it "should correctly deal with one Set-Cookie header with one cookie inside" do
|
27
|
+
net_http_res = double('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"]})
|
28
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
29
|
+
response.headers[:set_cookie].should eq ["main_page=main_page_no_rewrite; path=/; expires=Tue, 20-Jan-2015 15:03:14 GMT"]
|
30
|
+
response.cookies.should eq({ "main_page" => "main_page_no_rewrite" })
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should correctly deal with multiple cookies [multiple Set-Cookie headers]" do
|
34
|
+
net_http_res = double('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"]})
|
35
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
36
|
+
response.headers[:set_cookie].should eq ["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"]
|
37
|
+
response.cookies.should eq({
|
38
|
+
"main_page" => "main_page_no_rewrite",
|
39
|
+
"remember_me" => "",
|
40
|
+
"user" => "somebody"
|
41
|
+
})
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should correctly deal with multiple cookies [one Set-Cookie header with multiple cookies]" do
|
45
|
+
net_http_res = double('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"]})
|
46
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
47
|
+
response.cookies.should eq({
|
48
|
+
"main_page" => "main_page_no_rewrite",
|
49
|
+
"remember_me" => "",
|
50
|
+
"user" => "somebody"
|
51
|
+
})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "exceptions processing" do
|
56
|
+
it "should return itself for normal codes" do
|
57
|
+
(200..206).each do |code|
|
58
|
+
net_http_res = double('net http response', :code => '200')
|
59
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
60
|
+
response.return! @request
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should throw an exception for other codes" do
|
65
|
+
RestClient::Exceptions::EXCEPTIONS_MAP.each_key do |code|
|
66
|
+
unless (200..207).include? code
|
67
|
+
net_http_res = double('net http response', :code => code.to_i)
|
68
|
+
response = RestClient::Response.create('abc', net_http_res, {})
|
69
|
+
lambda { response.return!}.should raise_error
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "redirection" do
|
77
|
+
|
78
|
+
it "follows a redirection when the request is a get" do
|
79
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
80
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
81
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should eq 'Foo'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "follows a redirection and keep the parameters" do
|
85
|
+
stub_request(:get, 'http://foo:bar@some/resource').with(:headers => {'Accept' => 'application/json'}).to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
86
|
+
stub_request(:get, 'http://foo:bar@new/resource').with(:headers => {'Accept' => 'application/json'}).to_return(:body => 'Foo')
|
87
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :user => 'foo', :password => 'bar', :headers => {:accept => :json}).body.should eq 'Foo'
|
88
|
+
end
|
89
|
+
|
90
|
+
it "follows a redirection and keep the cookies" do
|
91
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Set-Cookie' => 'Foo=Bar', 'Location' => 'http://new/resource', })
|
92
|
+
stub_request(:get, 'http://new/resource').with(:headers => {'Cookie' => 'Foo=Bar'}).to_return(:body => 'Qux')
|
93
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should eq 'Qux'
|
94
|
+
end
|
95
|
+
|
96
|
+
it "doesn't follow a 301 when the request is a post" do
|
97
|
+
net_http_res = double('net http response', :code => 301)
|
98
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|
99
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::MovedPermanently)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "doesn't follow a 302 when the request is a post" do
|
103
|
+
net_http_res = double('net http response', :code => 302)
|
104
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|
105
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::Found)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "doesn't follow a 307 when the request is a post" do
|
109
|
+
net_http_res = double('net http response', :code => 307)
|
110
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :post})
|
111
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::TemporaryRedirect)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "doesn't follow a redirection when the request is a put" do
|
115
|
+
net_http_res = double('net http response', :code => 301)
|
116
|
+
response = RestClient::Response.create('abc', net_http_res, {:method => :put})
|
117
|
+
lambda { response.return!(@request)}.should raise_error(RestClient::MovedPermanently)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "follows a redirection when the request is a post and result is a 303" do
|
121
|
+
stub_request(:put, 'http://some/resource').to_return(:body => '', :status => 303, :headers => {'Location' => 'http://new/resource'})
|
122
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
123
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :put).body.should eq 'Foo'
|
124
|
+
end
|
125
|
+
|
126
|
+
it "follows a redirection when the request is a head" do
|
127
|
+
stub_request(:head, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
128
|
+
stub_request(:head, 'http://new/resource').to_return(:body => 'Foo')
|
129
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :head).body.should eq 'Foo'
|
130
|
+
end
|
131
|
+
|
132
|
+
it "handles redirects with relative paths" do
|
133
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'index'})
|
134
|
+
stub_request(:get, 'http://some/index').to_return(:body => 'Foo')
|
135
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should eq 'Foo'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "handles redirects with relative path and query string" do
|
139
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'index?q=1'})
|
140
|
+
stub_request(:get, 'http://some/index?q=1').to_return(:body => 'Foo')
|
141
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should eq 'Foo'
|
142
|
+
end
|
143
|
+
|
144
|
+
it "follow a redirection when the request is a get and the response is in the 30x range" do
|
145
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
146
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
147
|
+
RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body.should eq 'Foo'
|
148
|
+
end
|
149
|
+
|
150
|
+
it "follows no more than 10 redirections before raising error" do
|
151
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
152
|
+
stub_request(:get, 'http://some/redirect-2').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
153
|
+
lambda { RestClient::Request.execute(:url => 'http://some/redirect-1', :method => :get) }.should raise_error(RestClient::MaxRedirectsReached)
|
154
|
+
WebMock.should have_requested(:get, 'http://some/redirect-2').times(10)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "follows no more than max_redirects redirections, if specified" do
|
158
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
159
|
+
stub_request(:get, 'http://some/redirect-2').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
160
|
+
lambda { RestClient::Request.execute(:url => 'http://some/redirect-1', :method => :get, :max_redirects => 5) }.should raise_error(RestClient::MaxRedirectsReached)
|
161
|
+
WebMock.should have_requested(:get, 'http://some/redirect-2').times(5)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
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 = double('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,220 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rest-client-maestro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 96448493
|
5
|
+
prerelease: true
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 7
|
9
|
+
- 2
|
10
|
+
- maestro
|
11
|
+
version: 1.7.2.maestro
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- REST Client Team
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2013-12-03 00:00:00 -08:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: mime-types
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 47
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 16
|
34
|
+
version: "1.16"
|
35
|
+
- - <
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
hash: 3
|
38
|
+
segments:
|
39
|
+
- 2
|
40
|
+
- 0
|
41
|
+
version: "2.0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id001
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: webmock
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ~>
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 7
|
53
|
+
segments:
|
54
|
+
- 1
|
55
|
+
- 4
|
56
|
+
version: "1.4"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id002
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 11
|
68
|
+
segments:
|
69
|
+
- 2
|
70
|
+
- 4
|
71
|
+
version: "2.4"
|
72
|
+
type: :development
|
73
|
+
version_requirements: *id003
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: netrc
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 13
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
- 7
|
86
|
+
- 7
|
87
|
+
version: 0.7.7
|
88
|
+
type: :runtime
|
89
|
+
version_requirements: *id004
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rdoc
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 27
|
99
|
+
segments:
|
100
|
+
- 2
|
101
|
+
- 4
|
102
|
+
- 2
|
103
|
+
version: 2.4.2
|
104
|
+
type: :runtime
|
105
|
+
version_requirements: *id005
|
106
|
+
description: "A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework style of specifying actions: get, put, post, delete."
|
107
|
+
email: rest.client@librelist.com
|
108
|
+
executables:
|
109
|
+
- restclient
|
110
|
+
extensions: []
|
111
|
+
|
112
|
+
extra_rdoc_files:
|
113
|
+
- README.rdoc
|
114
|
+
- history.md
|
115
|
+
files:
|
116
|
+
- .gitignore
|
117
|
+
- .rspec
|
118
|
+
- .ruby-version
|
119
|
+
- .travis.yml
|
120
|
+
- AUTHORS
|
121
|
+
- Gemfile
|
122
|
+
- README.rdoc
|
123
|
+
- Rakefile
|
124
|
+
- bin/restclient
|
125
|
+
- history.md
|
126
|
+
- lib/rest-client.rb
|
127
|
+
- lib/rest_client.rb
|
128
|
+
- lib/restclient.rb
|
129
|
+
- lib/restclient/abstract_response.rb
|
130
|
+
- lib/restclient/exceptions.rb
|
131
|
+
- lib/restclient/net_http_ext.rb
|
132
|
+
- lib/restclient/payload.rb
|
133
|
+
- lib/restclient/raw_response.rb
|
134
|
+
- lib/restclient/request.rb
|
135
|
+
- lib/restclient/resource.rb
|
136
|
+
- lib/restclient/response.rb
|
137
|
+
- rest-client-maestro.gemspec
|
138
|
+
- spec/integration/capath_equifax/578d5c04.0
|
139
|
+
- spec/integration/capath_equifax/594f1775.0
|
140
|
+
- spec/integration/capath_equifax/README
|
141
|
+
- spec/integration/capath_equifax/equifax.crt
|
142
|
+
- spec/integration/capath_verisign/415660c1.0
|
143
|
+
- spec/integration/capath_verisign/7651b327.0
|
144
|
+
- spec/integration/capath_verisign/README
|
145
|
+
- spec/integration/capath_verisign/verisign.crt
|
146
|
+
- spec/integration/certs/equifax.crt
|
147
|
+
- spec/integration/certs/verisign.crt
|
148
|
+
- spec/integration/integration_spec.rb
|
149
|
+
- spec/integration/request_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
- spec/unit/abstract_response_spec.rb
|
152
|
+
- spec/unit/exceptions_spec.rb
|
153
|
+
- spec/unit/master_shake.jpg
|
154
|
+
- spec/unit/payload_spec.rb
|
155
|
+
- spec/unit/raw_response_spec.rb
|
156
|
+
- spec/unit/request2_spec.rb
|
157
|
+
- spec/unit/request_spec.rb
|
158
|
+
- spec/unit/resource_spec.rb
|
159
|
+
- spec/unit/response_spec.rb
|
160
|
+
- spec/unit/restclient_spec.rb
|
161
|
+
has_rdoc: true
|
162
|
+
homepage: http://github.com/maestrodev/rest-client
|
163
|
+
licenses:
|
164
|
+
- MIT
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
|
168
|
+
require_paths:
|
169
|
+
- lib
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
hash: 3
|
176
|
+
segments:
|
177
|
+
- 0
|
178
|
+
version: "0"
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
none: false
|
181
|
+
requirements:
|
182
|
+
- - ">"
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
hash: 25
|
185
|
+
segments:
|
186
|
+
- 1
|
187
|
+
- 3
|
188
|
+
- 1
|
189
|
+
version: 1.3.1
|
190
|
+
requirements: []
|
191
|
+
|
192
|
+
rubyforge_project:
|
193
|
+
rubygems_version: 1.3.7
|
194
|
+
signing_key:
|
195
|
+
specification_version: 3
|
196
|
+
summary: Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.
|
197
|
+
test_files:
|
198
|
+
- spec/integration/capath_equifax/578d5c04.0
|
199
|
+
- spec/integration/capath_equifax/594f1775.0
|
200
|
+
- spec/integration/capath_equifax/README
|
201
|
+
- spec/integration/capath_equifax/equifax.crt
|
202
|
+
- spec/integration/capath_verisign/415660c1.0
|
203
|
+
- spec/integration/capath_verisign/7651b327.0
|
204
|
+
- spec/integration/capath_verisign/README
|
205
|
+
- spec/integration/capath_verisign/verisign.crt
|
206
|
+
- spec/integration/certs/equifax.crt
|
207
|
+
- spec/integration/certs/verisign.crt
|
208
|
+
- spec/integration/integration_spec.rb
|
209
|
+
- spec/integration/request_spec.rb
|
210
|
+
- spec/spec_helper.rb
|
211
|
+
- spec/unit/abstract_response_spec.rb
|
212
|
+
- spec/unit/exceptions_spec.rb
|
213
|
+
- spec/unit/master_shake.jpg
|
214
|
+
- spec/unit/payload_spec.rb
|
215
|
+
- spec/unit/raw_response_spec.rb
|
216
|
+
- spec/unit/request2_spec.rb
|
217
|
+
- spec/unit/request_spec.rb
|
218
|
+
- spec/unit/resource_spec.rb
|
219
|
+
- spec/unit/response_spec.rb
|
220
|
+
- spec/unit/restclient_spec.rb
|