rest-client 1.7.0.rc1-x86-mingw32
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/AUTHORS +81 -0
- data/Gemfile +11 -0
- data/LICENSE +21 -0
- data/README.rdoc +325 -0
- data/Rakefile +117 -0
- data/bin/restclient +93 -0
- data/history.md +166 -0
- data/lib/rest-client.rb +2 -0
- data/lib/rest_client.rb +2 -0
- data/lib/restclient.rb +164 -0
- data/lib/restclient/abstract_response.rb +106 -0
- data/lib/restclient/exceptions.rb +203 -0
- data/lib/restclient/payload.rb +240 -0
- data/lib/restclient/platform.rb +30 -0
- data/lib/restclient/raw_response.rb +34 -0
- data/lib/restclient/request.rb +582 -0
- data/lib/restclient/resource.rb +169 -0
- data/lib/restclient/response.rb +24 -0
- data/lib/restclient/version.rb +7 -0
- data/lib/restclient/windows.rb +8 -0
- data/lib/restclient/windows/root_certs.rb +105 -0
- data/rest-client.gemspec +30 -0
- data/rest-client.windows.gemspec +19 -0
- data/spec/integration/capath_digicert/244b5494.0 +19 -0
- data/spec/integration/capath_digicert/81b9768f.0 +19 -0
- data/spec/integration/capath_digicert/README +8 -0
- data/spec/integration/capath_digicert/digicert.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/digicert.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 +104 -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 +905 -0
- data/spec/unit/resource_spec.rb +133 -0
- data/spec/unit/response_spec.rb +166 -0
- data/spec/unit/restclient_spec.rb +79 -0
- data/spec/unit/windows/root_certs_spec.rb +22 -0
- metadata +241 -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,79 @@
|
|
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
|
+
describe 'version' do
|
74
|
+
it 'has a version ~> 1.7.0.alpha' do
|
75
|
+
ver = Gem::Version.new(RestClient.version)
|
76
|
+
Gem::Requirement.new('~> 1.7.0.alpha').should be_satisfied_by(ver)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'RestClient::Windows::RootCerts',
|
4
|
+
:if => RestClient::Platform.windows? do
|
5
|
+
let(:x509_store) { RestClient::Windows::RootCerts.instance.to_a }
|
6
|
+
|
7
|
+
it 'should return at least one X509 certificate' do
|
8
|
+
expect(x509_store.to_a).to have_at_least(1).items
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should return an X509 certificate with a subject' do
|
12
|
+
x509 = x509_store.first
|
13
|
+
|
14
|
+
expect(x509.subject.to_s).to match(/CN=.*/)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should return X509 certificate objects' do
|
18
|
+
x509_store.each do |cert|
|
19
|
+
cert.should be_a(OpenSSL::X509::Certificate)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rest-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.0.rc1
|
5
|
+
platform: x86-mingw32
|
6
|
+
authors:
|
7
|
+
- REST Client Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: webmock
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-doc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.4.2
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '5.0'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.4.2
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '5.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: mime-types
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: netrc
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.7'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.7'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: ffi
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.9'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.9'
|
131
|
+
description: 'A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework
|
132
|
+
style of specifying actions: get, put, post, delete.'
|
133
|
+
email: rest.client@librelist.com
|
134
|
+
executables:
|
135
|
+
- restclient
|
136
|
+
extensions: []
|
137
|
+
extra_rdoc_files:
|
138
|
+
- README.rdoc
|
139
|
+
- history.md
|
140
|
+
files:
|
141
|
+
- ".gitignore"
|
142
|
+
- ".rspec"
|
143
|
+
- ".travis.yml"
|
144
|
+
- AUTHORS
|
145
|
+
- Gemfile
|
146
|
+
- LICENSE
|
147
|
+
- README.rdoc
|
148
|
+
- Rakefile
|
149
|
+
- bin/restclient
|
150
|
+
- history.md
|
151
|
+
- lib/rest-client.rb
|
152
|
+
- lib/rest_client.rb
|
153
|
+
- lib/restclient.rb
|
154
|
+
- lib/restclient/abstract_response.rb
|
155
|
+
- lib/restclient/exceptions.rb
|
156
|
+
- lib/restclient/payload.rb
|
157
|
+
- lib/restclient/platform.rb
|
158
|
+
- lib/restclient/raw_response.rb
|
159
|
+
- lib/restclient/request.rb
|
160
|
+
- lib/restclient/resource.rb
|
161
|
+
- lib/restclient/response.rb
|
162
|
+
- lib/restclient/version.rb
|
163
|
+
- lib/restclient/windows.rb
|
164
|
+
- lib/restclient/windows/root_certs.rb
|
165
|
+
- rest-client.gemspec
|
166
|
+
- rest-client.windows.gemspec
|
167
|
+
- spec/integration/capath_digicert/244b5494.0
|
168
|
+
- spec/integration/capath_digicert/81b9768f.0
|
169
|
+
- spec/integration/capath_digicert/README
|
170
|
+
- spec/integration/capath_digicert/digicert.crt
|
171
|
+
- spec/integration/capath_verisign/415660c1.0
|
172
|
+
- spec/integration/capath_verisign/7651b327.0
|
173
|
+
- spec/integration/capath_verisign/README
|
174
|
+
- spec/integration/capath_verisign/verisign.crt
|
175
|
+
- spec/integration/certs/digicert.crt
|
176
|
+
- spec/integration/certs/verisign.crt
|
177
|
+
- spec/integration/integration_spec.rb
|
178
|
+
- spec/integration/request_spec.rb
|
179
|
+
- spec/spec_helper.rb
|
180
|
+
- spec/unit/abstract_response_spec.rb
|
181
|
+
- spec/unit/exceptions_spec.rb
|
182
|
+
- spec/unit/master_shake.jpg
|
183
|
+
- spec/unit/payload_spec.rb
|
184
|
+
- spec/unit/raw_response_spec.rb
|
185
|
+
- spec/unit/request2_spec.rb
|
186
|
+
- spec/unit/request_spec.rb
|
187
|
+
- spec/unit/resource_spec.rb
|
188
|
+
- spec/unit/response_spec.rb
|
189
|
+
- spec/unit/restclient_spec.rb
|
190
|
+
- spec/unit/windows/root_certs_spec.rb
|
191
|
+
homepage: https://github.com/rest-client/rest-client
|
192
|
+
licenses:
|
193
|
+
- MIT
|
194
|
+
metadata: {}
|
195
|
+
post_install_message:
|
196
|
+
rdoc_options: []
|
197
|
+
require_paths:
|
198
|
+
- lib
|
199
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: 1.9.2
|
204
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 1.3.1
|
209
|
+
requirements: []
|
210
|
+
rubyforge_project:
|
211
|
+
rubygems_version: 2.2.2
|
212
|
+
signing_key:
|
213
|
+
specification_version: 4
|
214
|
+
summary: Simple HTTP and REST client for Ruby, inspired by microframework syntax for
|
215
|
+
specifying actions.
|
216
|
+
test_files:
|
217
|
+
- spec/integration/capath_digicert/244b5494.0
|
218
|
+
- spec/integration/capath_digicert/81b9768f.0
|
219
|
+
- spec/integration/capath_digicert/README
|
220
|
+
- spec/integration/capath_digicert/digicert.crt
|
221
|
+
- spec/integration/capath_verisign/415660c1.0
|
222
|
+
- spec/integration/capath_verisign/7651b327.0
|
223
|
+
- spec/integration/capath_verisign/README
|
224
|
+
- spec/integration/capath_verisign/verisign.crt
|
225
|
+
- spec/integration/certs/digicert.crt
|
226
|
+
- spec/integration/certs/verisign.crt
|
227
|
+
- spec/integration/integration_spec.rb
|
228
|
+
- spec/integration/request_spec.rb
|
229
|
+
- spec/spec_helper.rb
|
230
|
+
- spec/unit/abstract_response_spec.rb
|
231
|
+
- spec/unit/exceptions_spec.rb
|
232
|
+
- spec/unit/master_shake.jpg
|
233
|
+
- spec/unit/payload_spec.rb
|
234
|
+
- spec/unit/raw_response_spec.rb
|
235
|
+
- spec/unit/request2_spec.rb
|
236
|
+
- spec/unit/request_spec.rb
|
237
|
+
- spec/unit/resource_spec.rb
|
238
|
+
- spec/unit/response_spec.rb
|
239
|
+
- spec/unit/restclient_spec.rb
|
240
|
+
- spec/unit/windows/root_certs_spec.rb
|
241
|
+
has_rdoc:
|