angus-remote 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWMwMTViZThkMmM0ODg4YjJiYTM5M2M0NjlmNjUzNjFiYTRjMGJmNA==
4
+ MzliNzg0N2I4NTU1NzhlOGQyODJhMTQ0NjljNjNhYzc0NmU1NzExMw==
5
5
  data.tar.gz: !binary |-
6
- MTFjZjRhZmM0OTVlMWYyYzQyMTE1YzEzOTJjM2MzYjVlZDQ0NmQ5ZA==
6
+ YWEyMDlmMmZmZDMwNDFkMjA0ZjMwM2ZiOTE3OGU4MDJmMjk1YzljNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODY3Yzc3MjkxMWY4MGQ5MzcyNmJjNjk5NzA1NGFmNDBmOTJhYzQ4YzBjNTNl
10
- MDZlOWI3MzRmMzZlMzBiY2Y2Njg5OWViNGYwY2RiNDUwN2ExZTRmMDI0Yjc3
11
- YzQxZjAxZGE3MDE1ZjM5YzNmYTMyMjNhMmUyMjI2NmNiYTg5Y2U=
9
+ NTM3ZmI0OTRiODViMjNiZmMzZTIzNjJlMTVlNDZhNjQzNjU3NjBhZjI4NTUy
10
+ ZGNjMTFkZGJkNDVkZTdlNzIyMjVkYTkwY2ZhY2YyOTBhMDYwNWFkNGE1YTU5
11
+ MmQ1M2NmYWM0NDBhNjA0NjNiMjhhNDJhM2RkNWU1ZGVjZTU2NTc=
12
12
  data.tar.gz: !binary |-
13
- NjRiMTM4OTlkNTdmMWZiZjk1MzU5YWI1ZTQwMDE3NjZjZTQxNjBiOGNkYWU0
14
- NTRkODUxYjQzNDg2NDIzYjA1NDQzZWRjYTA1NDZiMDNlZWJlMWNkNzNhODZm
15
- OWQ0ZTllZDUyM2IxYTc1MmI5ZWUyOTliNTRmNWM2ODEwOTJhMjc=
13
+ MThhM2RlNjBkYjcyNTc3Njk5ZTkxYjllNDNlZTAxNTRlMTUwMjBmZjNiMmRh
14
+ NTBhMDM3YWZkNjA0ZTFlOGM3OGNmZWEzMDVlYTc2ZDUwZDExNWUzN2JjYjRk
15
+ NTQ1NGQxYmUwMGYzZmVmYzdjOTEzZGEyZTJmYTgyZmY5MWU1MDc=
@@ -17,13 +17,15 @@ module Angus
17
17
 
18
18
  elements.each do |name, value|
19
19
  if value.is_a?(Angus::Remote::Response::Hash)
20
- value.to_hash
20
+ hash[name] = value.to_hash
21
21
  elsif value.is_a?(Array)
22
22
  hash[name] = build_hash_from_array(value)
23
23
  else
24
24
  hash[name] = value
25
25
  end
26
26
  end
27
+
28
+ hash
27
29
  end
28
30
 
29
31
  private
@@ -1,7 +1,7 @@
1
1
  module Angus
2
2
  module Remote
3
3
 
4
- VERSION = '0.0.15'
4
+ VERSION = '0.0.16'
5
5
 
6
6
  end
7
7
  end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ require 'angus/remote/response/hash'
4
+
5
+ describe Angus::Remote::Response::Hash do
6
+
7
+ let(:response_class) do
8
+ Class.new do
9
+ include Angus::Remote::Response::Hash
10
+
11
+ def initialize(elements)
12
+ @elements = elements
13
+ end
14
+
15
+ end
16
+ end
17
+
18
+ subject(:response) { response_class.new(elements) }
19
+
20
+ describe '#to_hash' do
21
+
22
+ context 'when a elements has a single level' do
23
+ let(:elements) { { :id => rand(1_000), :customer_fields => %w[a b c] } }
24
+
25
+ it 'returns the flat elements' do
26
+ expect(response.to_hash).to eq(elements)
27
+ end
28
+ end
29
+
30
+ context 'when a nested responses elements as a hash' do
31
+ let(:brand_elements) { { :id => rand(1_000), :name => 'Acme' } }
32
+ let(:elements) { { :id => rand(1_000), :brand => response_class.new(brand_elements) } }
33
+
34
+ it 'returns the flat elements' do
35
+ expect(response.to_hash).to include(:brand => brand_elements)
36
+ end
37
+ end
38
+
39
+ context 'when a nested responses elements as an array' do
40
+ let(:division_elements) { { :id => rand(1_000), :name => 'Acme Division' } }
41
+ let(:commission_elements) { { :id => rand(1_000), :name => 'Acme Commission',
42
+ :divisions => [response_class.new(division_elements)] } }
43
+
44
+ let(:elements) { { :id => rand(1_000),
45
+ :commissions => [[commission_elements[:id],
46
+ response_class.new(commission_elements)]] } }
47
+
48
+ it 'returns the flat elements' do
49
+ commission = commission_elements.merge(:divisions => [division_elements])
50
+ expect(response.to_hash).to include(:commissions => [[commission[:id], commission]])
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angus-remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Gomez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-26 00:00:00.000000000 Z
12
+ date: 2014-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: angus-sdoc
@@ -240,6 +240,7 @@ files:
240
240
  - spec/angus/remote/http/query_params_spec.rb
241
241
  - spec/angus/remote/proxy_client_utils_spec.rb
242
242
  - spec/angus/remote/response/builder_spec.rb
243
+ - spec/angus/remote/response/hash_spec.rb
243
244
  - spec/angus/remote/service_directory_spec.rb
244
245
  - spec/angus/remote/utils_spec.rb
245
246
  homepage: http://mooveit.github.io/angus-remote
@@ -267,12 +268,13 @@ signing_key:
267
268
  specification_version: 4
268
269
  summary: Client for building service objects.
269
270
  test_files:
270
- - spec/angus/remote/service_directory_spec.rb
271
271
  - spec/angus/remote/proxy_client_utils_spec.rb
272
- - spec/angus/remote/http/query_params_spec.rb
272
+ - spec/angus/remote/client_spec.rb
273
+ - spec/angus/remote/builder_spec.rb
274
+ - spec/angus/remote/utils_spec.rb
273
275
  - spec/angus/remote/http/multipart_spec.rb
276
+ - spec/angus/remote/http/query_params_spec.rb
274
277
  - spec/angus/remote/http/multipart_methods/multipart_base_spec.rb
275
- - spec/angus/remote/utils_spec.rb
278
+ - spec/angus/remote/service_directory_spec.rb
276
279
  - spec/angus/remote/response/builder_spec.rb
277
- - spec/angus/remote/client_spec.rb
278
- - spec/angus/remote/builder_spec.rb
280
+ - spec/angus/remote/response/hash_spec.rb