rest-core 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+
2
+ require 'rest-core/test'
3
+
4
+ describe RC::RestClient do
5
+ describe 'POST Payload' do
6
+ after do
7
+ WebMock.reset!
8
+ end
9
+
10
+ client = RC::Builder.client
11
+ client.builder.run(RC::RestClient)
12
+ path = 'http://example.com'
13
+ ok = 'OK'
14
+ c = client.new
15
+
16
+ post = lambda do |payload, body|
17
+ stub_request(:post, path).with(:body => body).to_return(:body => ok)
18
+ c.post(path, payload).should.eq ok
19
+ end
20
+
21
+ should 'post with string' do
22
+ post['string', 'string']
23
+ end
24
+
25
+ should 'post with file' do
26
+ File.open(__FILE__) do |f|
27
+ b = f.read
28
+ f.rewind
29
+ post[f, b]
30
+ end
31
+ end
32
+
33
+ should 'post with socket' do
34
+ rd, wr = IO.pipe
35
+ wr.write('socket')
36
+ wr.close
37
+ post[rd, 'socket']
38
+ end
39
+ end
40
+ end
data/test/test_timeout.rb CHANGED
@@ -2,25 +2,23 @@
2
2
  require 'rest-core/test'
3
3
 
4
4
  describe RC::Timeout do
5
+ before do
6
+ @app = RC::Timeout.new(RC::Dry.new, 0)
7
+ end
8
+
5
9
  after do
6
10
  WebMock.reset!
7
11
  RR.verify
8
12
  end
9
13
 
10
- def setup_app
11
- RC::Timeout.new(RC::Dry.new, 0)
12
- end
13
-
14
14
  should 'bypass timeout if timeout is 0' do
15
- app = setup_app
16
- mock(app).monitor.times(0)
17
- app.call({}){ |e| e.should.eq({}) }
15
+ mock(@app).monitor.times(0)
16
+ @app.call({}){ |e| e.should.eq({}) }
18
17
  end
19
18
 
20
19
  should 'run the monitor to setup timeout' do
21
- app = setup_app
22
20
  env = {'timeout' => 2}
23
- mock.proxy(app).monitor(env).times(1)
24
- app.call(env){|e| e[RC::TIMER].should.kind_of?(RC::Timeout::TimerThread)}
21
+ mock.proxy(@app).monitor(env).times(1)
22
+ @app.call(env){|e| e[RC::TIMER].should.kind_of?(RC::Timeout::TimerThread)}
25
23
  end
26
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cardinal Blue
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-30 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -26,7 +26,7 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  description: |-
29
- Modular Ruby clients interface for REST APIs
29
+ Modular Ruby clients interface for REST APIs.
30
30
 
31
31
  There has been an explosion in the number of REST APIs available today.
32
32
  To address the need for a way to access these APIs easily and elegantly,
@@ -98,6 +98,7 @@ files:
98
98
  - lib/rest-core/util/hmac.rb
99
99
  - lib/rest-core/util/json.rb
100
100
  - lib/rest-core/util/parse_query.rb
101
+ - lib/rest-core/util/payload.rb
101
102
  - lib/rest-core/version.rb
102
103
  - lib/rest-core/wrapper.rb
103
104
  - rest-core.gemspec
@@ -108,8 +109,9 @@ files:
108
109
  - test/test_cache.rb
109
110
  - test/test_client.rb
110
111
  - test/test_client_oauth1.rb
112
+ - test/test_default_payload.rb
111
113
  - test/test_default_query.rb
112
- - test/test_em_http_request.rb
114
+ - test/test_em-http-request.rb
113
115
  - test/test_error_detector.rb
114
116
  - test/test_error_detector_http.rb
115
117
  - test/test_error_handler.rb
@@ -118,14 +120,26 @@ files:
118
120
  - test/test_json_response.rb
119
121
  - test/test_oauth1_header.rb
120
122
  - test/test_payload.rb
123
+ - test/test_rest-client.rb
121
124
  - test/test_simple.rb
122
125
  - test/test_timeout.rb
123
126
  - test/test_universal.rb
124
127
  - test/test_wrapper.rb
125
128
  homepage: https://github.com/cardinalblue/rest-core
126
- licenses: []
129
+ licenses:
130
+ - Apache License 2.0
127
131
  metadata: {}
128
- post_install_message:
132
+ post_install_message: |
133
+ # [rest-core] Incompatible changes for POST requests:
134
+
135
+ * We no longer support Rails-like POST payload, like translating
136
+ `{:foo => [1, 2]}` to `'foo[]=1&foo[]=2'`. It would now be translated to
137
+ `'foo=1&foo=2'`. If you like `'foo[]'` as the key, simply pass it as
138
+ `{'foo[]' => [1, 2]}`.
139
+
140
+ * This also applies to nested hashes like `{:foo => {:bar => 1}`. If you
141
+ want that behaviour, just pass `{'foo[bar]' => 1}` which would then be
142
+ translated to `'foo[bar]=1'`.
129
143
  rdoc_options: []
130
144
  require_paths:
131
145
  - lib
@@ -141,18 +155,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
155
  version: '0'
142
156
  requirements: []
143
157
  rubyforge_project:
144
- rubygems_version: 2.0.0
158
+ rubygems_version: 2.0.3
145
159
  signing_key:
146
160
  specification_version: 4
147
- summary: Modular Ruby clients interface for REST APIs
161
+ summary: Modular Ruby clients interface for REST APIs.
148
162
  test_files:
149
163
  - test/test_auth_basic.rb
150
164
  - test/test_builder.rb
151
165
  - test/test_cache.rb
152
166
  - test/test_client.rb
153
167
  - test/test_client_oauth1.rb
168
+ - test/test_default_payload.rb
154
169
  - test/test_default_query.rb
155
- - test/test_em_http_request.rb
170
+ - test/test_em-http-request.rb
156
171
  - test/test_error_detector.rb
157
172
  - test/test_error_detector_http.rb
158
173
  - test/test_error_handler.rb
@@ -161,6 +176,7 @@ test_files:
161
176
  - test/test_json_response.rb
162
177
  - test/test_oauth1_header.rb
163
178
  - test/test_payload.rb
179
+ - test/test_rest-client.rb
164
180
  - test/test_simple.rb
165
181
  - test/test_timeout.rb
166
182
  - test/test_universal.rb