acfs 1.0.0.dev.1.b305 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/CHANGELOG.md +64 -0
- data/README.md +2 -2
- data/acfs.gemspec +4 -4
- data/lib/acfs.rb +7 -5
- data/lib/acfs/adapter/base.rb +0 -2
- data/lib/acfs/adapter/typhoeus.rb +17 -13
- data/lib/acfs/collections/paginatable.rb +10 -10
- data/lib/acfs/configuration.rb +4 -5
- data/lib/acfs/errors.rb +10 -9
- data/lib/acfs/global.rb +16 -7
- data/lib/acfs/location.rb +11 -11
- data/lib/acfs/middleware/base.rb +1 -2
- data/lib/acfs/middleware/json.rb +27 -0
- data/lib/acfs/middleware/logger.rb +0 -2
- data/lib/acfs/middleware/msgpack.rb +30 -0
- data/lib/acfs/middleware/print.rb +0 -2
- data/lib/acfs/middleware/serializer.rb +39 -0
- data/lib/acfs/operation.rb +5 -5
- data/lib/acfs/request.rb +4 -4
- data/lib/acfs/request/callbacks.rb +2 -3
- data/lib/acfs/resource.rb +2 -2
- data/lib/acfs/resource/attributes.rb +10 -37
- data/lib/acfs/resource/attributes/base.rb +10 -19
- data/lib/acfs/resource/attributes/boolean.rb +10 -8
- data/lib/acfs/resource/attributes/date_time.rb +6 -9
- data/lib/acfs/resource/attributes/dict.rb +37 -0
- data/lib/acfs/resource/attributes/float.rb +11 -5
- data/lib/acfs/resource/attributes/integer.rb +7 -5
- data/lib/acfs/resource/attributes/list.rb +13 -6
- data/lib/acfs/resource/attributes/string.rb +3 -5
- data/lib/acfs/resource/attributes/uuid.rb +8 -17
- data/lib/acfs/resource/loadable.rb +0 -1
- data/lib/acfs/resource/locatable.rb +0 -4
- data/lib/acfs/resource/operational.rb +0 -2
- data/lib/acfs/resource/persistence.rb +17 -17
- data/lib/acfs/resource/query_methods.rb +3 -5
- data/lib/acfs/resource/service.rb +0 -2
- data/lib/acfs/resource/validation.rb +0 -2
- data/lib/acfs/response.rb +1 -2
- data/lib/acfs/response/formats.rb +1 -2
- data/lib/acfs/response/status.rb +3 -5
- data/lib/acfs/runner.rb +21 -11
- data/lib/acfs/service.rb +4 -6
- data/lib/acfs/service/middleware.rb +20 -30
- data/lib/acfs/service/middleware/stack.rb +63 -0
- data/lib/acfs/singleton_resource.rb +0 -2
- data/lib/acfs/stub.rb +30 -21
- data/lib/acfs/util.rb +1 -1
- data/lib/acfs/version.rb +4 -2
- data/spec/acfs/adapter/typhoeus_spec.rb +12 -4
- data/spec/acfs/collection_spec.rb +45 -33
- data/spec/acfs/configuration_spec.rb +9 -1
- data/spec/acfs/global_spec.rb +21 -3
- data/spec/acfs/middleware/json_spec.rb +63 -0
- data/spec/acfs/middleware/msgpack_spec.rb +60 -0
- data/spec/acfs/operation_spec.rb +10 -0
- data/spec/acfs/request/callbacks_spec.rb +8 -8
- data/spec/acfs/request_spec.rb +5 -5
- data/spec/acfs/resource/attributes/boolean_spec.rb +40 -9
- data/spec/acfs/resource/attributes/date_time_spec.rb +29 -35
- data/spec/acfs/resource/attributes/dict_spec.rb +75 -0
- data/spec/acfs/resource/attributes/float_spec.rb +48 -9
- data/spec/acfs/resource/attributes/integer_spec.rb +34 -0
- data/spec/acfs/resource/attributes/list_spec.rb +43 -19
- data/spec/acfs/resource/attributes/uuid_spec.rb +31 -54
- data/spec/acfs/resource/attributes_spec.rb +17 -31
- data/spec/acfs/resource/locatable_spec.rb +2 -2
- data/spec/acfs/resource/persistance_spec.rb +65 -34
- data/spec/acfs/resource/query_methods_spec.rb +87 -87
- data/spec/acfs/resource/validation_spec.rb +4 -5
- data/spec/acfs/response/formats_spec.rb +1 -1
- data/spec/acfs/response/status_spec.rb +1 -1
- data/spec/acfs/runner_spec.rb +28 -3
- data/spec/acfs/service/middleware_spec.rb +4 -20
- data/spec/acfs/service_spec.rb +3 -5
- data/spec/acfs/singleton_resource_spec.rb +1 -2
- data/spec/acfs/stub_spec.rb +137 -22
- data/spec/acfs_spec.rb +22 -19
- data/spec/spec_helper.rb +2 -1
- data/spec/support/service.rb +10 -6
- data/spec/support/shared/find_callbacks.rb +7 -7
- metadata +37 -30
- data/lib/acfs/middleware/json_decoder.rb +0 -16
- data/lib/acfs/middleware/json_encoder.rb +0 -20
- data/lib/acfs/middleware/msgpack_decoder.rb +0 -26
- data/lib/acfs/middleware/msgpack_encoder.rb +0 -19
- data/spec/acfs/middleware/json_decoder_spec.rb +0 -45
- data/spec/acfs/middleware/msgpack_decoder_spec.rb +0 -36
data/spec/acfs/stub_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Acfs::Stub do
|
|
14
14
|
|
15
15
|
describe '#called?' do
|
16
16
|
context 'without specified number' do
|
17
|
-
let!(:operation) { Acfs::Stub.resource MyUser, :read, with: {
|
17
|
+
let!(:operation) { Acfs::Stub.resource MyUser, :read, with: {id: 1}, return: {id: 1, name: 'John Smith', age: 32} }
|
18
18
|
|
19
19
|
it 'should allow to test if stub was called' do
|
20
20
|
MyUser.find 1
|
@@ -38,8 +38,8 @@ describe Acfs::Stub do
|
|
38
38
|
describe '.resource' do
|
39
39
|
context 'with ambiguous stubs' do
|
40
40
|
before do
|
41
|
-
Acfs::Stub.resource MyUser, :read, with: {
|
42
|
-
Acfs::Stub.resource MyUser, :read, with: {
|
41
|
+
Acfs::Stub.resource MyUser, :read, with: {id: 1}, return: {id: 1, name: 'John Smith', age: 32}
|
42
|
+
Acfs::Stub.resource MyUser, :read, with: {id: 1}, raise: :not_found
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should raise error' do
|
@@ -51,9 +51,9 @@ describe Acfs::Stub do
|
|
51
51
|
|
52
52
|
context 'with read action' do
|
53
53
|
before do
|
54
|
-
Acfs::Stub.resource MyUser, :read, with: {
|
55
|
-
Acfs::Stub.resource MyUser, :read, with: {
|
56
|
-
Acfs::Stub.resource MyUser, :read, with: {
|
54
|
+
Acfs::Stub.resource MyUser, :read, with: {id: 1}, return: {id: 1, name: 'John Smith', age: 32}
|
55
|
+
Acfs::Stub.resource MyUser, :read, with: {id: 2}, raise: SpecialCustomError
|
56
|
+
Acfs::Stub.resource MyUser, :read, with: {id: 3}, raise: :not_found
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should allow to stub resource reads' do
|
@@ -81,8 +81,8 @@ describe Acfs::Stub do
|
|
81
81
|
|
82
82
|
context 'with type parameter' do
|
83
83
|
before do
|
84
|
-
Acfs::Stub.resource Computer, :read, with: {
|
85
|
-
Acfs::Stub.resource Computer, :read, with: {
|
84
|
+
Acfs::Stub.resource Computer, :read, with: {id: 1}, return: {id: 1, type: 'PC'}
|
85
|
+
Acfs::Stub.resource Computer, :read, with: {id: 2}, return: {id: 2, type: 'Mac'}
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should create inherited type' do
|
@@ -99,8 +99,8 @@ describe Acfs::Stub do
|
|
99
99
|
|
100
100
|
context 'with create action' do
|
101
101
|
before do
|
102
|
-
Acfs::Stub.resource Session, :create, with: {
|
103
|
-
Acfs::Stub.resource Session, :create, with:
|
102
|
+
Acfs::Stub.resource Session, :create, with: {ident: 'john@exmaple.org', password: 's3cr3t'}, return: {id: 'longhash', user: 1}
|
103
|
+
Acfs::Stub.resource Session, :create, with: ->(op) { op.data[:ident] == 'john@exmaple.org' && op.data[:password] == 'wrong' }, raise: 422
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should allow stub resource creation' do
|
@@ -111,16 +111,16 @@ describe Acfs::Stub do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should allow to raise error' do
|
114
|
-
expect
|
114
|
+
expect do
|
115
115
|
Session.create! ident: 'john@exmaple.org', password: 'wrong'
|
116
|
-
|
116
|
+
end.to raise_error(::Acfs::InvalidResource)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
context 'with list action' do
|
121
121
|
before do
|
122
122
|
Acfs::Stub.resource MyUser, :list,
|
123
|
-
return: [{
|
123
|
+
return: [{id: 1, name: 'John Smith', age: 32}, {id: 2, name: 'Anon', age: 12}]
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'should return collection' do
|
@@ -158,23 +158,35 @@ describe Acfs::Stub do
|
|
158
158
|
context 'with header' do
|
159
159
|
before do
|
160
160
|
Acfs::Stub.resource Comment, :list,
|
161
|
-
|
162
|
-
|
161
|
+
return: [{id: 1, text: 'Foo'}, {id: 2, text: 'Bar'}],
|
162
|
+
headers: headers
|
163
163
|
end
|
164
164
|
|
165
165
|
let!(:comments) { Comment.all }
|
166
|
-
let(:headers)
|
166
|
+
let(:headers) do
|
167
|
+
{
|
168
|
+
'X-Total-Pages' => '2',
|
169
|
+
'X-Total-Count' => '10'
|
170
|
+
}
|
171
|
+
end
|
167
172
|
subject { Acfs.run; comments }
|
168
173
|
|
169
174
|
its(:total_pages) { should eq 2 }
|
175
|
+
its(:total_count) { should eq 10 }
|
170
176
|
end
|
171
177
|
end
|
172
178
|
|
173
179
|
context 'with update action' do
|
174
180
|
before do
|
175
|
-
Acfs::Stub.resource MyUser, :read, with: {
|
176
|
-
Acfs::Stub.resource MyUser, :update, with: {
|
177
|
-
Acfs::Stub.resource MyUser, :update, with: {
|
181
|
+
Acfs::Stub.resource MyUser, :read, with: {id: 1}, return: {id: 1, name: 'John Smith', age: 32}
|
182
|
+
Acfs::Stub.resource MyUser, :update, with: {id: 1, name: 'John Smith', age: 22}, return: {id: 1, name: 'John Smith', age: 23}
|
183
|
+
Acfs::Stub.resource MyUser, :update, with: {id: 1, name: 'John Smith', age: 0}, raise: 422
|
184
|
+
end
|
185
|
+
|
186
|
+
let!(:update_stub) do
|
187
|
+
Acfs::Stub.resource MyUser, :update,
|
188
|
+
with: {id: 1, name: 'Jane Smith'},
|
189
|
+
return: ->(op) { Hash[op.data.map {|k, v| [k, v.to_s.upcase] }] }
|
178
190
|
end
|
179
191
|
|
180
192
|
it 'should allow stub resource update' do
|
@@ -194,9 +206,43 @@ describe Acfs::Stub do
|
|
194
206
|
user.age = 0
|
195
207
|
user.save
|
196
208
|
|
197
|
-
expect
|
209
|
+
expect do
|
198
210
|
user.save!
|
199
|
-
|
211
|
+
end.to raise_error(::Acfs::InvalidResource)
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should match partial :with' do
|
215
|
+
user = MyUser.find 1
|
216
|
+
Acfs.run
|
217
|
+
|
218
|
+
user.age = 5
|
219
|
+
user.name = 'Jane Smith'
|
220
|
+
user.save!
|
221
|
+
|
222
|
+
expect(update_stub).to be_called
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should process response body' do
|
226
|
+
user = MyUser.find 1
|
227
|
+
Acfs.run
|
228
|
+
|
229
|
+
user.age = 5
|
230
|
+
user.name = 'Jane Smith'
|
231
|
+
user.save!
|
232
|
+
|
233
|
+
expect(user.name).to eq 'JANE SMITH'
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context 'with create action' do
|
238
|
+
before do
|
239
|
+
Acfs::Stub.resource MyUser, :create, with: {name: 'John Smith', age: 0}, raise: 422
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'should allow to raise error' do
|
243
|
+
expect do
|
244
|
+
MyUser.create! name: 'John Smith', age: 0
|
245
|
+
end.to raise_error(::Acfs::InvalidResource)
|
200
246
|
end
|
201
247
|
end
|
202
248
|
end
|
@@ -205,7 +251,7 @@ describe Acfs::Stub do
|
|
205
251
|
context 'when enabled' do
|
206
252
|
before do
|
207
253
|
Acfs::Stub.allow_requests = true
|
208
|
-
stub_request(:get, 'http://users.example.org/users/2').to_return response(
|
254
|
+
stub_request(:get, 'http://users.example.org/users/2').to_return response(id: 2, name: 'John', age: 26)
|
209
255
|
end
|
210
256
|
|
211
257
|
it 'should allow real requests' do
|
@@ -225,4 +271,73 @@ describe Acfs::Stub do
|
|
225
271
|
end
|
226
272
|
end
|
227
273
|
end
|
274
|
+
|
275
|
+
describe 'accept?' do
|
276
|
+
subject { stub.accept?(op) }
|
277
|
+
|
278
|
+
context 'with a match in params' do
|
279
|
+
let(:op) do
|
280
|
+
double('operation').tap do |op|
|
281
|
+
allow(op).to receive(:full_params).and_return(id: 1337, blub: 'abc')
|
282
|
+
allow(op).to receive(:data).and_return({})
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
let(:stub) { Acfs::Stub.resource MyUser, :read, with: {id: 1337} }
|
287
|
+
|
288
|
+
it { is_expected.to be true }
|
289
|
+
end
|
290
|
+
|
291
|
+
context 'with a match in data' do
|
292
|
+
let(:op) do
|
293
|
+
double('operation').tap do |op|
|
294
|
+
allow(op).to receive(:full_params).and_return({})
|
295
|
+
allow(op).to receive(:data).and_return(id: 1337, blub: 'abc')
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
let(:stub) { Acfs::Stub.resource MyUser, :read, with: {id: 1337} }
|
300
|
+
|
301
|
+
it { is_expected.to be true }
|
302
|
+
end
|
303
|
+
|
304
|
+
context 'with no match in params nor data' do
|
305
|
+
let(:op) do
|
306
|
+
double('operation').tap do |op|
|
307
|
+
allow(op).to receive(:full_params).and_return(id: 1337)
|
308
|
+
allow(op).to receive(:data).and_return({})
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
let(:stub) { Acfs::Stub.resource MyUser, :read, with: {abc: '123'} }
|
313
|
+
|
314
|
+
it { is_expected.to be false }
|
315
|
+
end
|
316
|
+
|
317
|
+
context 'with a wrong match' do
|
318
|
+
let(:op) do
|
319
|
+
double('operation').tap do |op|
|
320
|
+
allow(op).to receive(:full_params).and_return(id: 1337, blub: 'abc')
|
321
|
+
allow(op).to receive(:data).and_return({})
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
let(:stub) { Acfs::Stub.resource MyUser, :read, with: {id: 1337, blub: '123'} }
|
326
|
+
|
327
|
+
it { is_expected.to be false }
|
328
|
+
end
|
329
|
+
|
330
|
+
context 'with a missing match' do
|
331
|
+
let(:op) do
|
332
|
+
double('operation').tap do |op|
|
333
|
+
allow(op).to receive(:full_params).and_return(id: 1337, blub: 'abc')
|
334
|
+
allow(op).to receive(:data).and_return({})
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
let(:stub) { Acfs::Stub.resource MyUser, :read, with: {id: 1337, answer: 42} }
|
339
|
+
|
340
|
+
it { is_expected.to be false }
|
341
|
+
end
|
342
|
+
end
|
228
343
|
end
|
data/spec/acfs_spec.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Acfs' do
|
4
|
-
|
5
4
|
before do
|
6
|
-
stub_request(:get, 'http://users.example.org/users').to_return response([{
|
7
|
-
stub_request(:get, 'http://users.example.org/users/2').to_return response(
|
8
|
-
stub_request(:get, 'http://users.example.org/users/3').to_return response(
|
9
|
-
stub_request(:get, 'http://users.example.org/users/100').to_return response(
|
10
|
-
stub_request(:get, 'http://users.example.org/users/2/friends').to_return response([{
|
11
|
-
stub_request(:get, 'http://comments.example.org/comments?user=2').to_return response([{
|
5
|
+
stub_request(:get, 'http://users.example.org/users').to_return response([{id: 1, name: 'Anon', age: 12}, {id: 2, name: 'John', age: 26}])
|
6
|
+
stub_request(:get, 'http://users.example.org/users/2').to_return response(id: 2, name: 'John', age: 26)
|
7
|
+
stub_request(:get, 'http://users.example.org/users/3').to_return response(id: 3, name: 'Miraculix', age: 122)
|
8
|
+
stub_request(:get, 'http://users.example.org/users/100').to_return response(id: 100, name: 'Jimmy', age: 45)
|
9
|
+
stub_request(:get, 'http://users.example.org/users/2/friends').to_return response([{id: 1, name: 'Anon', age: 12}])
|
10
|
+
stub_request(:get, 'http://comments.example.org/comments?user=2').to_return response([{id: 1, text: 'Comment #1'}, {id: 2, text: 'Comment #2'}])
|
12
11
|
end
|
13
12
|
|
14
13
|
it 'should update single resource synchronously' do
|
15
14
|
stub = stub_request(:put, 'http://users.example.org/users/2')
|
16
|
-
|
15
|
+
.to_return {|request| {body: request.body, headers: {'Content-Type' => request.headers['Content-Type']}} }
|
17
16
|
|
18
17
|
@user = MyUser.find 2
|
19
18
|
Acfs.run
|
@@ -24,7 +23,7 @@ describe 'Acfs' do
|
|
24
23
|
@user.name = 'Johnny'
|
25
24
|
|
26
25
|
expect(@user).to be_changed
|
27
|
-
expect(@user).
|
26
|
+
expect(@user).to be_persisted
|
28
27
|
|
29
28
|
@user.save
|
30
29
|
|
@@ -34,7 +33,7 @@ describe 'Acfs' do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
it 'should create a single resource synchronously' do
|
37
|
-
stub = stub_request(:post, 'http://users.example.org/sessions').to_return response(
|
36
|
+
stub = stub_request(:post, 'http://users.example.org/sessions').to_return response(id: 'sessionhash', user: 1)
|
38
37
|
|
39
38
|
session = Session.create ident: 'Anon'
|
40
39
|
|
@@ -58,11 +57,11 @@ describe 'Acfs' do
|
|
58
57
|
|
59
58
|
describe 'singleton' do
|
60
59
|
before do
|
61
|
-
stub_request(:get, 'http://users.example.org/singles?user_id=5').to_return response(
|
60
|
+
stub_request(:get, 'http://users.example.org/singles?user_id=5').to_return response(score: 250, user_id: 5)
|
62
61
|
end
|
63
62
|
|
64
63
|
it 'should create a singleton resource' do
|
65
|
-
stub = stub_request(:post, 'http://users.example.org/singles').to_return response(
|
64
|
+
stub = stub_request(:post, 'http://users.example.org/singles').to_return response(score: 250, user_id: 5)
|
66
65
|
|
67
66
|
@single = Single.new user_id: 5, score: 250
|
68
67
|
expect(@single.new?).to eq true
|
@@ -83,10 +82,12 @@ describe 'Acfs' do
|
|
83
82
|
end
|
84
83
|
|
85
84
|
it 'should update singleton resource' do
|
86
|
-
stub = stub_request(:put, 'http://users.example.org/singles').to_return
|
85
|
+
stub = stub_request(:put, 'http://users.example.org/singles').to_return do |request|
|
86
|
+
{
|
87
87
|
body: request.body,
|
88
|
-
headers: {
|
89
|
-
|
88
|
+
headers: {'Content-Type' => request.headers['Content-Type']}
|
89
|
+
}
|
90
|
+
end
|
90
91
|
|
91
92
|
@single = Single.find user_id: 5
|
92
93
|
Acfs.run
|
@@ -102,10 +103,12 @@ describe 'Acfs' do
|
|
102
103
|
end
|
103
104
|
|
104
105
|
it 'should delete singleton resource' do
|
105
|
-
stub = stub_request(:delete, 'http://users.example.org/singles').to_return
|
106
|
+
stub = stub_request(:delete, 'http://users.example.org/singles').to_return do |request|
|
107
|
+
{
|
106
108
|
body: request.body,
|
107
|
-
headers: {
|
108
|
-
|
109
|
+
headers: {'Content-Type' => request.headers['Content-Type']}
|
110
|
+
}
|
111
|
+
end
|
109
112
|
|
110
113
|
@single = Single.find user_id: 5
|
111
114
|
Acfs.run
|
@@ -118,7 +121,7 @@ describe 'Acfs' do
|
|
118
121
|
end
|
119
122
|
|
120
123
|
it 'should raise error when calling `all\'' do
|
121
|
-
expect{ Single.all }.to raise_error ::Acfs::UnsupportedOperation
|
124
|
+
expect { Single.all }.to raise_error ::Acfs::UnsupportedOperation
|
122
125
|
end
|
123
126
|
end
|
124
127
|
|
data/spec/spec_helper.rb
CHANGED
@@ -12,8 +12,9 @@ require 'bundler'
|
|
12
12
|
Bundler.require
|
13
13
|
|
14
14
|
require 'acfs'
|
15
|
+
require 'webmock/rspec'
|
15
16
|
|
16
|
-
Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f}
|
17
|
+
Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
|
17
18
|
|
18
19
|
RSpec.configure do |config|
|
19
20
|
# ## Mock Framework
|
data/spec/support/service.rb
CHANGED
@@ -33,7 +33,6 @@ class Profile < Acfs::SingletonResource
|
|
33
33
|
end
|
34
34
|
|
35
35
|
class Customer < MyUser
|
36
|
-
|
37
36
|
end
|
38
37
|
|
39
38
|
class MyUserWithValidations < MyUser
|
@@ -43,9 +42,9 @@ end
|
|
43
42
|
|
44
43
|
class Session < Acfs::Resource
|
45
44
|
service UserService, path: {
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
list: 'users/:user_id/sessions',
|
46
|
+
delete: 'users/:user_id/sessions/del/:id',
|
47
|
+
update: nil
|
49
48
|
}
|
50
49
|
|
51
50
|
attribute :id, :string
|
@@ -72,11 +71,9 @@ class Computer < Acfs::Resource
|
|
72
71
|
end
|
73
72
|
|
74
73
|
class PC < Computer
|
75
|
-
|
76
74
|
end
|
77
75
|
|
78
76
|
class Mac < Computer
|
79
|
-
|
80
77
|
end
|
81
78
|
|
82
79
|
class Single < Acfs::SingletonResource
|
@@ -85,3 +82,10 @@ class Single < Acfs::SingletonResource
|
|
85
82
|
attribute :score, :integer
|
86
83
|
attribute :user_id, :integer
|
87
84
|
end
|
85
|
+
|
86
|
+
class PathArguments < Acfs::Resource
|
87
|
+
service UserService, path: ':required_arg/users/'
|
88
|
+
|
89
|
+
attribute :id, :integer
|
90
|
+
attribute :required_arg, :string
|
91
|
+
end
|
@@ -2,23 +2,23 @@ shared_examples 'a query method with multi-callback support' do
|
|
2
2
|
let(:cb) { Proc.new }
|
3
3
|
|
4
4
|
it 'should invoke callback' do
|
5
|
-
expect
|
5
|
+
expect do |cb|
|
6
6
|
action.call cb
|
7
7
|
Acfs.run
|
8
|
-
|
8
|
+
end.to yield_with_args
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should invoke multiple callbacks' do
|
12
|
-
expect
|
12
|
+
expect do |cb|
|
13
13
|
object = action.call cb
|
14
14
|
Acfs.add_callback object, &cb
|
15
15
|
Acfs.run
|
16
|
-
|
16
|
+
end.to yield_control.exactly(2).times
|
17
17
|
end
|
18
18
|
|
19
19
|
describe 'callback' do
|
20
20
|
it 'should be invoked with resource' do
|
21
|
-
proc =
|
21
|
+
proc = proc {}
|
22
22
|
expect(proc).to receive(:call) do |res|
|
23
23
|
expect(res).to equal @object
|
24
24
|
expect(res).to be_loaded
|
@@ -29,8 +29,8 @@ shared_examples 'a query method with multi-callback support' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should invoke multiple callback with loaded resource' do
|
32
|
-
proc1 =
|
33
|
-
proc2 =
|
32
|
+
proc1 = proc {}
|
33
|
+
proc2 = proc {}
|
34
34
|
expect(proc1).to receive(:call) do |user|
|
35
35
|
expect(user).to equal @object
|
36
36
|
expect(user).to be_loaded
|
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionpack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: multi_json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: typhoeus
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '1.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.3'
|
111
111
|
description: API Client For Services
|
@@ -129,12 +129,11 @@ files:
|
|
129
129
|
- lib/acfs/global.rb
|
130
130
|
- lib/acfs/location.rb
|
131
131
|
- lib/acfs/middleware/base.rb
|
132
|
-
- lib/acfs/middleware/
|
133
|
-
- lib/acfs/middleware/json_encoder.rb
|
132
|
+
- lib/acfs/middleware/json.rb
|
134
133
|
- lib/acfs/middleware/logger.rb
|
135
|
-
- lib/acfs/middleware/
|
136
|
-
- lib/acfs/middleware/msgpack_encoder.rb
|
134
|
+
- lib/acfs/middleware/msgpack.rb
|
137
135
|
- lib/acfs/middleware/print.rb
|
136
|
+
- lib/acfs/middleware/serializer.rb
|
138
137
|
- lib/acfs/operation.rb
|
139
138
|
- lib/acfs/request.rb
|
140
139
|
- lib/acfs/request/callbacks.rb
|
@@ -143,6 +142,7 @@ files:
|
|
143
142
|
- lib/acfs/resource/attributes/base.rb
|
144
143
|
- lib/acfs/resource/attributes/boolean.rb
|
145
144
|
- lib/acfs/resource/attributes/date_time.rb
|
145
|
+
- lib/acfs/resource/attributes/dict.rb
|
146
146
|
- lib/acfs/resource/attributes/float.rb
|
147
147
|
- lib/acfs/resource/attributes/integer.rb
|
148
148
|
- lib/acfs/resource/attributes/list.rb
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/acfs/runner.rb
|
165
165
|
- lib/acfs/service.rb
|
166
166
|
- lib/acfs/service/middleware.rb
|
167
|
+
- lib/acfs/service/middleware/stack.rb
|
167
168
|
- lib/acfs/singleton_resource.rb
|
168
169
|
- lib/acfs/stub.rb
|
169
170
|
- lib/acfs/util.rb
|
@@ -173,13 +174,16 @@ files:
|
|
173
174
|
- spec/acfs/collection_spec.rb
|
174
175
|
- spec/acfs/configuration_spec.rb
|
175
176
|
- spec/acfs/global_spec.rb
|
176
|
-
- spec/acfs/middleware/
|
177
|
-
- spec/acfs/middleware/
|
177
|
+
- spec/acfs/middleware/json_spec.rb
|
178
|
+
- spec/acfs/middleware/msgpack_spec.rb
|
179
|
+
- spec/acfs/operation_spec.rb
|
178
180
|
- spec/acfs/request/callbacks_spec.rb
|
179
181
|
- spec/acfs/request_spec.rb
|
180
182
|
- spec/acfs/resource/attributes/boolean_spec.rb
|
181
183
|
- spec/acfs/resource/attributes/date_time_spec.rb
|
184
|
+
- spec/acfs/resource/attributes/dict_spec.rb
|
182
185
|
- spec/acfs/resource/attributes/float_spec.rb
|
186
|
+
- spec/acfs/resource/attributes/integer_spec.rb
|
183
187
|
- spec/acfs/resource/attributes/list_spec.rb
|
184
188
|
- spec/acfs/resource/attributes/uuid_spec.rb
|
185
189
|
- spec/acfs/resource/attributes_spec.rb
|
@@ -214,17 +218,17 @@ require_paths:
|
|
214
218
|
- lib
|
215
219
|
required_ruby_version: !ruby/object:Gem::Requirement
|
216
220
|
requirements:
|
217
|
-
- -
|
221
|
+
- - ">="
|
218
222
|
- !ruby/object:Gem::Version
|
219
223
|
version: '0'
|
220
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
225
|
requirements:
|
222
|
-
- -
|
226
|
+
- - ">="
|
223
227
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
228
|
+
version: '0'
|
225
229
|
requirements: []
|
226
230
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.
|
231
|
+
rubygems_version: 2.5.1
|
228
232
|
signing_key:
|
229
233
|
specification_version: 4
|
230
234
|
summary: An abstract API base client for service oriented application.
|
@@ -233,13 +237,16 @@ test_files:
|
|
233
237
|
- spec/acfs/collection_spec.rb
|
234
238
|
- spec/acfs/configuration_spec.rb
|
235
239
|
- spec/acfs/global_spec.rb
|
236
|
-
- spec/acfs/middleware/
|
237
|
-
- spec/acfs/middleware/
|
240
|
+
- spec/acfs/middleware/json_spec.rb
|
241
|
+
- spec/acfs/middleware/msgpack_spec.rb
|
242
|
+
- spec/acfs/operation_spec.rb
|
238
243
|
- spec/acfs/request/callbacks_spec.rb
|
239
244
|
- spec/acfs/request_spec.rb
|
240
245
|
- spec/acfs/resource/attributes/boolean_spec.rb
|
241
246
|
- spec/acfs/resource/attributes/date_time_spec.rb
|
247
|
+
- spec/acfs/resource/attributes/dict_spec.rb
|
242
248
|
- spec/acfs/resource/attributes/float_spec.rb
|
249
|
+
- spec/acfs/resource/attributes/integer_spec.rb
|
243
250
|
- spec/acfs/resource/attributes/list_spec.rb
|
244
251
|
- spec/acfs/resource/attributes/uuid_spec.rb
|
245
252
|
- spec/acfs/resource/attributes_spec.rb
|