acfs 0.23.2 → 0.24.0.b210

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: df206319b5c8ed76be17036d7d9aba9fa7be6ee5
4
- data.tar.gz: 4527b5b268b86c9c97fe4054918e59c893bc8d9c
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmM5ZDRlOGNlODlhYzMzMTY0MjM0OTVmNmZkOWRhYWU1MzkyMjI0Zg==
5
+ data.tar.gz: !binary |-
6
+ ZDQ1YWIwOTBjNDA4NDM0MDI1MGNiMDc5NWVjMzE5NTQ1ZjI0OWY3Ng==
5
7
  SHA512:
6
- metadata.gz: 1952d07e7558d6989cb781561ac08fede50723723db53f3e976bc803ea1a7f6587791ec2eff46cf702ed01e6dd0c2dbe7e4b281a21535fbc461b63efbffafbbf
7
- data.tar.gz: a41330102704b7bddf4471e65d58c6840ffeb9456b497f198b9ba824578c4c9e07238b249bd2fc25f2b2bc7510bc114c57f08bc9910b06a8938ed7482defe00c
8
+ metadata.gz: !binary |-
9
+ YWJiMzlkMWFiYTc3YjhlMWYwZWQ1MGQ3MzgzZDZkMjFmZTY3MWQ3MzhkNWNl
10
+ ZGMzZjE2MzJmY2Y4ODczZGYxOTRkNmMxZjQ5YjA0NGM0Y2IzY2VjN2Q5NDNi
11
+ ZTdjMjA1MmI4NzIxNmVjMjA4NTMxNWIyOTRjYmZiNjFmYmEzYWM=
12
+ data.tar.gz: !binary |-
13
+ Zjg5Mzk0MGE1OWQ2Y2ZkNmQwYTY2NzVmNDdmYzU4Mzc3NTY2ODYwZTVkNjQ0
14
+ N2M0ODczM2Q3NDBkNGRiNjNiZjEyYTA0Y2RhNTg4YmQ1MGUxZmE2NzNlNmU0
15
+ YWZkMzY3YjFiN2U5OGM1ZDc1YThhYTY1ZTE1YjFiM2FkYWFkOTI=
@@ -4,7 +4,7 @@ rvm:
4
4
  - 2.0.0
5
5
  - 1.9.3
6
6
  - jruby
7
- - rbx-19mode
7
+ - rbx
8
8
  gemfile:
9
9
  - gemfiles/Gemfile.rails-4-0
10
10
  - gemfiles/Gemfile.rails-3-2
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.24.0
4
+
5
+ * Fix issues with stubs using type inheritance
6
+ * Allow '1' as true value for bool attributes (Tino Junge)
7
+
3
8
  ## 0.23.2
4
9
 
5
10
  * Fix regression in delegator usage by #find due to resource type inheritance.
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gem 'webmock', '~> 1.7'
6
6
  gem 'rake'
7
7
  gem 'rspec'
8
8
  gem 'coveralls'
9
- gem 'json', '~> 1.7.7'
9
+ gem 'json', '~> 1.8.1'
10
10
 
11
11
  # Doc
12
12
  group :development do
@@ -19,6 +19,10 @@ end
19
19
 
20
20
  # Platform specific development dependencies
21
21
  #
22
+ platform :rbx do
23
+ gem 'rubysl', '~> 2.0'
24
+ gem 'rubinius-coverage'
25
+ end
22
26
  gem 'msgpack', platform: :ruby
23
27
  gem 'msgpack-jruby', require: 'msgpack', platform: :jruby
24
28
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Coverage Status](https://coveralls.io/repos/jgraichen/acfs/badge.png?branch=master)](https://coveralls.io/r/jgraichen/acfs)
6
6
  [![Code Climate](https://codeclimate.com/github/jgraichen/acfs.png)](https://codeclimate.com/github/jgraichen/acfs)
7
7
  [![Dependency Status](https://gemnasium.com/jgraichen/acfs.png)](https://gemnasium.com/jgraichen/acfs)
8
- [![RubyDoc Documentation](https://raw.github.com/jgraichen/shields/master/rubydoc.png)](http://rubydoc.info/github/jgraichen/acfs/master/frames)
8
+ [![RubyDoc Documentation](http://b.repl.ca/v1/rubydoc-here-blue.png)](http://rubydoc.info/github/jgraichen/acfs/master/frames)
9
9
 
10
10
  Acfs is a library to develop API client libraries for single services within a larger service oriented application.
11
11
 
@@ -22,7 +22,10 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency 'activemodel', '>= 3.1'
23
23
  spec.add_runtime_dependency 'actionpack', '>= 3.1'
24
24
  spec.add_runtime_dependency 'multi_json'
25
- spec.add_runtime_dependency 'typhoeus'
25
+
26
+ # Bundle update w/o version resolves to 0.3.3 ...
27
+ spec.add_runtime_dependency 'typhoeus', '>= 0.6.5'
28
+
26
29
  spec.add_runtime_dependency 'rack'
27
30
 
28
31
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -18,7 +18,7 @@ module Acfs::Model
18
18
  #
19
19
  class Boolean < Base
20
20
 
21
- TRUE_VALUES = %w(true on yes)
21
+ TRUE_VALUES = %w(true on yes 1)
22
22
 
23
23
  # @api public
24
24
  #
@@ -8,6 +8,7 @@ module Acfs
8
8
  class Operation
9
9
  attr_reader :action, :params, :resource, :data, :callback
10
10
  delegate :service, to: :resource
11
+ delegate :call, to: :callback
11
12
 
12
13
  def initialize(resource, action, opts = {}, &block)
13
14
  @resource = resource
@@ -11,7 +11,10 @@ module Acfs
11
11
 
12
12
  def initialize(opts)
13
13
  @opts = opts
14
- @opts[:with].stringify_keys! if @opts[:with].respond_to? :stringify_keys
14
+
15
+ @opts[:with].stringify_keys! if @opts[:with].is_a? Hash
16
+ @opts[:return].stringify_keys! if @opts[:return].is_a? Hash
17
+ @opts[:return].map! { |h| h.stringify_keys! if h.is_a? Hash } if @opts[:return].is_a? Array
15
18
  end
16
19
 
17
20
  def accept?(op)
@@ -20,7 +23,7 @@ module Acfs
20
23
  params = op.full_params.stringify_keys
21
24
  data = op.data.stringify_keys
22
25
 
23
- opts[:with] == params || data == opts[:with]
26
+ opts[:with] == params || data == opts[:with] || (opts[:with].nil? && params.empty? && data.empty?)
24
27
  end
25
28
 
26
29
  def calls
@@ -38,7 +41,7 @@ module Acfs
38
41
  if (err = opts[:raise])
39
42
  raise_error op, err, opts[:return]
40
43
  elsif (data = opts[:return])
41
- op.callback.call data
44
+ op.call data
42
45
  else
43
46
  raise ArgumentError, 'Unsupported stub.'
44
47
  end
@@ -1,8 +1,8 @@
1
1
  module Acfs
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 23
5
- PATCH = 2
4
+ MINOR = 24
5
+ PATCH = 0
6
6
  STAGE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Acfs::Model::Attributes::Boolean do
4
+ subject { Acfs::Model::Attributes::Boolean.new }
5
+
6
+ describe 'cast' do
7
+ it 'should preserve boolean values' do
8
+ expect(subject.cast(false)).to eq false
9
+ expect(subject.cast(true)).to eq true
10
+ end
11
+
12
+ it 'should cast TRUE_VALUES to true' do
13
+ expect(subject.cast('yes')).to eq true
14
+ expect(subject.cast('on')).to eq true
15
+ expect(subject.cast('true')).to eq true
16
+ expect(subject.cast('1')).to eq true
17
+ end
18
+
19
+ it 'should cast any other value to false' do
20
+ expect(subject.cast('')).to eq false
21
+ expect(subject.cast('wrong')).to eq false
22
+ expect(subject.cast('random')).to eq false
23
+ end
24
+ end
25
+ end
@@ -10,10 +10,6 @@ describe Acfs::Stub do
10
10
 
11
11
  before do
12
12
  Acfs::Stub.allow_requests = false
13
-
14
- #Acfs::Stub.read(MyUser).with(id: 5).and_return({ id: 5, name: 'John', age: 32 })
15
- #Acfs::Stub.read(MyUser).with(id: 6).and_raise(:not_found)
16
- #Acfs::Stub.create(MyUser).with(name: '', age: 12).and_return(:invalid, errors: { name: [ 'must be present ']})
17
13
  end
18
14
 
19
15
  describe '#called?' do
@@ -82,6 +78,23 @@ describe Acfs::Stub do
82
78
  expect { Acfs.run }.to raise_error(Acfs::ResourceNotFound)
83
79
  end
84
80
  end
81
+
82
+ context 'with type parameter' do
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' }
86
+ end
87
+
88
+ it 'should create inherited type' do
89
+ pc = Computer.find 1
90
+ mac = Computer.find 2
91
+
92
+ Acfs.run
93
+
94
+ expect(pc).to be_a PC
95
+ expect(mac).to be_a Mac
96
+ end
97
+ end
85
98
  end
86
99
 
87
100
  context 'with create action' do
@@ -104,6 +117,45 @@ describe Acfs::Stub do
104
117
  end
105
118
  end
106
119
 
120
+ context 'with list action' do
121
+ before do
122
+ Acfs::Stub.resource MyUser, :list,
123
+ return: [{ id: 1, name: 'John Smith', age: 32 }, { id: 2, name: 'Anon', age: 12 }]
124
+ end
125
+
126
+ it 'should return collection' do
127
+ users = MyUser.all
128
+ Acfs.run
129
+
130
+ expect(users).to have(2).items
131
+ end
132
+
133
+ it 'should return defined resources' do
134
+ users = MyUser.all
135
+ Acfs.run
136
+
137
+ expect(users[0].id).to eq 1
138
+ expect(users[1].id).to eq 2
139
+ expect(users[0].name).to eq 'John Smith'
140
+ expect(users[1].name).to eq 'Anon'
141
+ end
142
+
143
+ context 'with type parameter' do
144
+ before do
145
+ Acfs::Stub.resource Computer, :list,
146
+ return: [{id: 1, type: 'PC'}, {id: 2, type: 'Mac'}]
147
+ end
148
+
149
+ it 'should create inherited type' do
150
+ computers = Computer.all
151
+ Acfs.run
152
+
153
+ expect(computers.first).to be_a PC
154
+ expect(computers.last).to be_a Mac
155
+ end
156
+ end
157
+ end
158
+
107
159
  context 'with update action' do
108
160
  before do
109
161
  Acfs::Stub.resource MyUser, :read, with: { id: 1 }, return: { id: 1, name: 'John Smith', age: 32 }
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.2
4
+ version: 0.24.0.b210
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-27 00:00:00.000000000 Z
11
+ date: 2013-11-29 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: 0.6.5
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: 0.6.5
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
@@ -179,6 +179,7 @@ files:
179
179
  - spec/acfs/configuration_spec.rb
180
180
  - spec/acfs/middleware/json_decoder_spec.rb
181
181
  - spec/acfs/middleware/msgpack_decoder_spec.rb
182
+ - spec/acfs/model/attributes/boolean_spec.rb
182
183
  - spec/acfs/model/attributes/date_time_spec.rb
183
184
  - spec/acfs/model/attributes/float_spec.rb
184
185
  - spec/acfs/model/attributes/list_spec.rb
@@ -212,17 +213,17 @@ require_paths:
212
213
  - lib
213
214
  required_ruby_version: !ruby/object:Gem::Requirement
214
215
  requirements:
215
- - - '>='
216
+ - - ! '>='
216
217
  - !ruby/object:Gem::Version
217
218
  version: '0'
218
219
  required_rubygems_version: !ruby/object:Gem::Requirement
219
220
  requirements:
220
- - - '>='
221
+ - - ! '>'
221
222
  - !ruby/object:Gem::Version
222
- version: '0'
223
+ version: 1.3.1
223
224
  requirements: []
224
225
  rubyforge_project:
225
- rubygems_version: 2.0.3
226
+ rubygems_version: 2.1.11
226
227
  signing_key:
227
228
  specification_version: 4
228
229
  summary: An abstract API base client for service oriented application.
@@ -230,6 +231,7 @@ test_files:
230
231
  - spec/acfs/configuration_spec.rb
231
232
  - spec/acfs/middleware/json_decoder_spec.rb
232
233
  - spec/acfs/middleware/msgpack_decoder_spec.rb
234
+ - spec/acfs/model/attributes/boolean_spec.rb
233
235
  - spec/acfs/model/attributes/date_time_spec.rb
234
236
  - spec/acfs/model/attributes/float_spec.rb
235
237
  - spec/acfs/model/attributes/list_spec.rb
@@ -253,4 +255,3 @@ test_files:
253
255
  - spec/spec_helper.rb
254
256
  - spec/support/response.rb
255
257
  - spec/support/service.rb
256
- has_rdoc: