acfs 0.50.0 → 1.0.0.dev.1.b297

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.
Files changed (90) hide show
  1. checksums.yaml +13 -5
  2. data/CHANGELOG.md +0 -80
  3. data/README.md +9 -8
  4. data/acfs.gemspec +7 -7
  5. data/lib/acfs.rb +5 -7
  6. data/lib/acfs/adapter/base.rb +2 -0
  7. data/lib/acfs/adapter/typhoeus.rb +13 -17
  8. data/lib/acfs/collections/paginatable.rb +10 -10
  9. data/lib/acfs/configuration.rb +5 -4
  10. data/lib/acfs/errors.rb +9 -10
  11. data/lib/acfs/global.rb +7 -16
  12. data/lib/acfs/location.rb +11 -11
  13. data/lib/acfs/middleware/base.rb +2 -1
  14. data/lib/acfs/middleware/json_decoder.rb +16 -0
  15. data/lib/acfs/middleware/json_encoder.rb +20 -0
  16. data/lib/acfs/middleware/logger.rb +2 -0
  17. data/lib/acfs/middleware/msgpack_decoder.rb +26 -0
  18. data/lib/acfs/middleware/msgpack_encoder.rb +19 -0
  19. data/lib/acfs/middleware/print.rb +2 -0
  20. data/lib/acfs/operation.rb +5 -5
  21. data/lib/acfs/request.rb +4 -4
  22. data/lib/acfs/request/callbacks.rb +3 -2
  23. data/lib/acfs/resource.rb +2 -2
  24. data/lib/acfs/resource/attributes.rb +38 -11
  25. data/lib/acfs/resource/attributes/base.rb +19 -10
  26. data/lib/acfs/resource/attributes/boolean.rb +8 -10
  27. data/lib/acfs/resource/attributes/date_time.rb +9 -6
  28. data/lib/acfs/resource/attributes/float.rb +5 -11
  29. data/lib/acfs/resource/attributes/integer.rb +5 -7
  30. data/lib/acfs/resource/attributes/list.rb +6 -13
  31. data/lib/acfs/resource/attributes/string.rb +5 -3
  32. data/lib/acfs/resource/attributes/uuid.rb +17 -8
  33. data/lib/acfs/resource/dirty.rb +15 -3
  34. data/lib/acfs/resource/loadable.rb +1 -0
  35. data/lib/acfs/resource/locatable.rb +4 -0
  36. data/lib/acfs/resource/operational.rb +2 -0
  37. data/lib/acfs/resource/persistence.rb +17 -17
  38. data/lib/acfs/resource/query_methods.rb +7 -8
  39. data/lib/acfs/resource/service.rb +2 -0
  40. data/lib/acfs/resource/validation.rb +4 -4
  41. data/lib/acfs/response.rb +2 -1
  42. data/lib/acfs/response/formats.rb +3 -2
  43. data/lib/acfs/response/status.rb +5 -3
  44. data/lib/acfs/runner.rb +11 -21
  45. data/lib/acfs/service.rb +6 -4
  46. data/lib/acfs/service/middleware.rb +30 -20
  47. data/lib/acfs/singleton_resource.rb +2 -0
  48. data/lib/acfs/stub.rb +21 -30
  49. data/lib/acfs/util.rb +1 -1
  50. data/lib/acfs/version.rb +4 -6
  51. data/spec/acfs/adapter/typhoeus_spec.rb +4 -12
  52. data/spec/acfs/collection_spec.rb +33 -45
  53. data/spec/acfs/configuration_spec.rb +1 -9
  54. data/spec/acfs/global_spec.rb +3 -21
  55. data/spec/acfs/middleware/json_decoder_spec.rb +45 -0
  56. data/spec/acfs/middleware/msgpack_decoder_spec.rb +36 -0
  57. data/spec/acfs/request/callbacks_spec.rb +8 -8
  58. data/spec/acfs/request_spec.rb +5 -5
  59. data/spec/acfs/resource/attributes/boolean_spec.rb +9 -40
  60. data/spec/acfs/resource/attributes/date_time_spec.rb +35 -29
  61. data/spec/acfs/resource/attributes/float_spec.rb +9 -48
  62. data/spec/acfs/resource/attributes/list_spec.rb +19 -43
  63. data/spec/acfs/resource/attributes/uuid_spec.rb +54 -31
  64. data/spec/acfs/resource/attributes_spec.rb +31 -17
  65. data/spec/acfs/resource/locatable_spec.rb +2 -2
  66. data/spec/acfs/resource/persistance_spec.rb +34 -65
  67. data/spec/acfs/resource/query_methods_spec.rb +90 -97
  68. data/spec/acfs/resource/validation_spec.rb +5 -4
  69. data/spec/acfs/response/formats_spec.rb +4 -4
  70. data/spec/acfs/response/status_spec.rb +1 -1
  71. data/spec/acfs/runner_spec.rb +3 -28
  72. data/spec/acfs/service/middleware_spec.rb +20 -4
  73. data/spec/acfs/service_spec.rb +5 -3
  74. data/spec/acfs/singleton_resource_spec.rb +2 -1
  75. data/spec/acfs/stub_spec.rb +22 -137
  76. data/spec/acfs_spec.rb +19 -22
  77. data/spec/spec_helper.rb +2 -3
  78. data/spec/support/service.rb +6 -10
  79. data/spec/support/shared/find_callbacks.rb +7 -7
  80. metadata +36 -43
  81. data/lib/acfs/middleware/json.rb +0 -27
  82. data/lib/acfs/middleware/msgpack.rb +0 -30
  83. data/lib/acfs/middleware/serializer.rb +0 -39
  84. data/lib/acfs/resource/attributes/dict.rb +0 -37
  85. data/lib/acfs/service/middleware/stack.rb +0 -63
  86. data/spec/acfs/middleware/json_spec.rb +0 -63
  87. data/spec/acfs/middleware/msgpack_spec.rb +0 -60
  88. data/spec/acfs/operation_spec.rb +0 -10
  89. data/spec/acfs/resource/attributes/dict_spec.rb +0 -75
  90. data/spec/acfs/resource/attributes/integer_spec.rb +0 -34
@@ -10,7 +10,7 @@ describe Acfs::Service do
10
10
  end
11
11
 
12
12
  describe '#initialize' do
13
- let(:options) { {path: 'abc', key: 'value'} }
13
+ let(:options) { { path: 'abc', key: 'value' } }
14
14
 
15
15
  it 'should set options' do
16
16
  expect(service.options).to eq(options)
@@ -19,14 +19,14 @@ describe Acfs::Service do
19
19
 
20
20
  describe '#location' do
21
21
  let(:resource) { Class.new }
22
- before { allow(resource).to receive(:location_default_path, &proc{|_a, p| p}) }
22
+ before { allow(resource).to receive(:location_default_path, &proc{|a, p| p}) }
23
23
 
24
24
  it 'should extract resource path name from given class' do
25
25
  expect(service.location(resource).to_s).to eq('/classes')
26
26
  end
27
27
 
28
28
  context 'with path options' do
29
- let(:options) { {path: 'abc'} }
29
+ let(:options) { { path: 'abc' } }
30
30
 
31
31
  it 'should have custom resource path' do
32
32
  expect(service.location(resource).to_s).to eq('/abc')
@@ -35,11 +35,13 @@ describe Acfs::Service do
35
35
  end
36
36
 
37
37
  describe '.base_url' do
38
+
38
39
  before do
39
40
  Acfs::Configuration.current.locate :test, 'http://abc.de/api/v1'
40
41
  end
41
42
 
42
43
  it 'should return configured URI for service' do
44
+
43
45
  expect(srv_class.base_url).to eq('http://abc.de/api/v1')
44
46
  end
45
47
  end
@@ -9,7 +9,8 @@ describe Acfs::SingletonResource do
9
9
  .to_return response id: 1
10
10
  end
11
11
 
12
- let(:action) { ->(cb) { model.find(&cb) } }
12
+ let(:action) { ->(cb){ model.find(&cb) } }
13
13
  it_should_behave_like 'a query method with multi-callback support'
14
14
  end
15
+
15
16
  end
@@ -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: {id: 1}, return: {id: 1, name: 'John Smith', age: 32} }
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: {id: 1}, return: {id: 1, name: 'John Smith', age: 32}
42
- Acfs::Stub.resource MyUser, :read, with: {id: 1}, raise: :not_found
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: {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
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: {id: 1}, return: {id: 1, type: 'PC'}
85
- Acfs::Stub.resource Computer, :read, with: {id: 2}, return: {id: 2, type: 'Mac'}
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: {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
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: lambda { |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 do
114
+ expect {
115
115
  Session.create! ident: 'john@exmaple.org', password: 'wrong'
116
- end.to raise_error(::Acfs::InvalidResource)
116
+ }.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: [{id: 1, name: 'John Smith', age: 32}, {id: 2, name: 'Anon', age: 12}]
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,35 +158,23 @@ describe Acfs::Stub do
158
158
  context 'with header' do
159
159
  before do
160
160
  Acfs::Stub.resource Comment, :list,
161
- return: [{id: 1, text: 'Foo'}, {id: 2, text: 'Bar'}],
162
- headers: headers
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) do
167
- {
168
- 'X-Total-Pages' => '2',
169
- 'X-Total-Count' => '10'
170
- }
171
- end
166
+ let(:headers) { {'X-Total-Pages' => '2'} }
172
167
  subject { Acfs.run; comments }
173
168
 
174
169
  its(:total_pages) { should eq 2 }
175
- its(:total_count) { should eq 10 }
176
170
  end
177
171
  end
178
172
 
179
173
  context 'with update action' do
180
174
  before do
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] }] }
175
+ Acfs::Stub.resource MyUser, :read, with: { id: 1 }, return: { id: 1, name: 'John Smith', age: 32 }
176
+ Acfs::Stub.resource MyUser, :update, with: { id: 1, name: 'John Smith', age: 22 }, return: { id: 1, name: 'John Smith', age: 23 }
177
+ Acfs::Stub.resource MyUser, :update, with: { id: 1, name: 'John Smith', age: 0 }, raise: 422
190
178
  end
191
179
 
192
180
  it 'should allow stub resource update' do
@@ -206,43 +194,9 @@ describe Acfs::Stub do
206
194
  user.age = 0
207
195
  user.save
208
196
 
209
- expect do
197
+ expect {
210
198
  user.save!
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)
199
+ }.to raise_error(::Acfs::InvalidResource)
246
200
  end
247
201
  end
248
202
  end
@@ -251,7 +205,7 @@ describe Acfs::Stub do
251
205
  context 'when enabled' do
252
206
  before do
253
207
  Acfs::Stub.allow_requests = true
254
- stub_request(:get, 'http://users.example.org/users/2').to_return response(id: 2, name: 'John', age: 26)
208
+ stub_request(:get, 'http://users.example.org/users/2').to_return response({ id: 2, name: 'John', age: 26 })
255
209
  end
256
210
 
257
211
  it 'should allow real requests' do
@@ -271,73 +225,4 @@ describe Acfs::Stub do
271
225
  end
272
226
  end
273
227
  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
343
228
  end
@@ -1,18 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Acfs' do
4
+
4
5
  before do
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'}])
6
+ stub_request(:get, 'http://users.example.org/users').to_return response([{ id: 1, name: 'Anon', age: 12 }, { id: 2, name: 'John', age: 26 }])
7
+ stub_request(:get, 'http://users.example.org/users/2').to_return response({ id: 2, name: 'John', age: 26 })
8
+ stub_request(:get, 'http://users.example.org/users/3').to_return response({ id: 3, name: 'Miraculix', age: 122 })
9
+ stub_request(:get, 'http://users.example.org/users/100').to_return response({ id:100, name: 'Jimmy', age: 45 })
10
+ stub_request(:get, 'http://users.example.org/users/2/friends').to_return response([{ id: 1, name: 'Anon', age: 12 }])
11
+ stub_request(:get, 'http://comments.example.org/comments?user=2').to_return response([{ id: 1, text: 'Comment #1' }, { id: 2, text: 'Comment #2' }])
11
12
  end
12
13
 
13
14
  it 'should update single resource synchronously' do
14
15
  stub = stub_request(:put, 'http://users.example.org/users/2')
15
- .to_return {|request| {body: request.body, headers: {'Content-Type' => request.headers['Content-Type']}} }
16
+ .to_return { |request| { body: request.body, headers: {'Content-Type' => request.headers['Content-Type']}} }
16
17
 
17
18
  @user = MyUser.find 2
18
19
  Acfs.run
@@ -23,7 +24,7 @@ describe 'Acfs' do
23
24
  @user.name = 'Johnny'
24
25
 
25
26
  expect(@user).to be_changed
26
- expect(@user).to be_persisted
27
+ expect(@user).to_not be_persisted
27
28
 
28
29
  @user.save
29
30
 
@@ -33,7 +34,7 @@ describe 'Acfs' do
33
34
  end
34
35
 
35
36
  it 'should create a single resource synchronously' do
36
- stub = stub_request(:post, 'http://users.example.org/sessions').to_return response(id: 'sessionhash', user: 1)
37
+ stub = stub_request(:post, 'http://users.example.org/sessions').to_return response({id: 'sessionhash', user: 1})
37
38
 
38
39
  session = Session.create ident: 'Anon'
39
40
 
@@ -57,11 +58,11 @@ describe 'Acfs' do
57
58
 
58
59
  describe 'singleton' do
59
60
  before do
60
- stub_request(:get, 'http://users.example.org/singles?user_id=5').to_return response(score: 250, user_id: 5)
61
+ stub_request(:get, 'http://users.example.org/singles?user_id=5').to_return response({ score: 250, user_id: 5 })
61
62
  end
62
63
 
63
64
  it 'should create a singleton resource' do
64
- stub = stub_request(:post, 'http://users.example.org/singles').to_return response(score: 250, user_id: 5)
65
+ stub = stub_request(:post, 'http://users.example.org/singles').to_return response({ score: 250, user_id: 5 })
65
66
 
66
67
  @single = Single.new user_id: 5, score: 250
67
68
  expect(@single.new?).to eq true
@@ -82,12 +83,10 @@ describe 'Acfs' do
82
83
  end
83
84
 
84
85
  it 'should update singleton resource' do
85
- stub = stub_request(:put, 'http://users.example.org/singles').to_return do |request|
86
- {
86
+ stub = stub_request(:put, 'http://users.example.org/singles').to_return { |request| {
87
87
  body: request.body,
88
- headers: {'Content-Type' => request.headers['Content-Type']}
89
- }
90
- end
88
+ headers: { 'Content-Type' => request.headers['Content-Type'] }
89
+ } }
91
90
 
92
91
  @single = Single.find user_id: 5
93
92
  Acfs.run
@@ -103,12 +102,10 @@ describe 'Acfs' do
103
102
  end
104
103
 
105
104
  it 'should delete singleton resource' do
106
- stub = stub_request(:delete, 'http://users.example.org/singles').to_return do |request|
107
- {
105
+ stub = stub_request(:delete, 'http://users.example.org/singles').to_return { |request| {
108
106
  body: request.body,
109
- headers: {'Content-Type' => request.headers['Content-Type']}
110
- }
111
- end
107
+ headers: { 'Content-Type' => request.headers['Content-Type'] }
108
+ } }
112
109
 
113
110
  @single = Single.find user_id: 5
114
111
  Acfs.run
@@ -121,7 +118,7 @@ describe 'Acfs' do
121
118
  end
122
119
 
123
120
  it 'should raise error when calling `all\'' do
124
- expect { Single.all }.to raise_error ::Acfs::UnsupportedOperation
121
+ expect{ Single.all }.to raise_error ::Acfs::UnsupportedOperation
125
122
  end
126
123
  end
127
124
 
@@ -9,12 +9,11 @@ if ENV['CI'] || (defined?(:RUBY_ENGINE) && RUBY_ENGINE != 'rbx')
9
9
  end
10
10
 
11
11
  require 'bundler'
12
- Bundler.require(:default, :test)
12
+ Bundler.require
13
13
 
14
14
  require 'acfs'
15
- require 'webmock/rspec'
16
15
 
17
- Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
16
+ Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f}
18
17
 
19
18
  RSpec.configure do |config|
20
19
  # ## Mock Framework
@@ -33,6 +33,7 @@ class Profile < Acfs::SingletonResource
33
33
  end
34
34
 
35
35
  class Customer < MyUser
36
+
36
37
  end
37
38
 
38
39
  class MyUserWithValidations < MyUser
@@ -42,9 +43,9 @@ end
42
43
 
43
44
  class Session < Acfs::Resource
44
45
  service UserService, path: {
45
- list: 'users/:user_id/sessions',
46
- delete: 'users/:user_id/sessions/del/:id',
47
- update: nil
46
+ list: 'users/:user_id/sessions',
47
+ delete: 'users/:user_id/sessions/del/:id',
48
+ update: nil
48
49
  }
49
50
 
50
51
  attribute :id, :string
@@ -71,9 +72,11 @@ class Computer < Acfs::Resource
71
72
  end
72
73
 
73
74
  class PC < Computer
75
+
74
76
  end
75
77
 
76
78
  class Mac < Computer
79
+
77
80
  end
78
81
 
79
82
  class Single < Acfs::SingletonResource
@@ -82,10 +85,3 @@ class Single < Acfs::SingletonResource
82
85
  attribute :score, :integer
83
86
  attribute :user_id, :integer
84
87
  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 do |cb|
5
+ expect { |cb|
6
6
  action.call cb
7
7
  Acfs.run
8
- end.to yield_with_args
8
+ }.to yield_with_args
9
9
  end
10
10
 
11
11
  it 'should invoke multiple callbacks' do
12
- expect do |cb|
12
+ expect { |cb|
13
13
  object = action.call cb
14
14
  Acfs.add_callback object, &cb
15
15
  Acfs.run
16
- end.to yield_control.exactly(2).times
16
+ }.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 = proc {}
21
+ proc = Proc.new { }
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 = proc {}
33
- proc2 = proc {}
32
+ proc1 = Proc.new { }
33
+ proc2 = Proc.new { }
34
34
  expect(proc1).to receive(:call) do |user|
35
35
  expect(user).to equal @object
36
36
  expect(user).to be_loaded