frenetic 0.0.2.alpha2 → 0.0.2.alpha3

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,11 @@ class Frenetic
10
10
  @links = []
11
11
  else
12
12
  load self.class.schema, attributes
13
- load attributes.resources.members, attributes.resources
13
+
14
+ # Load embedded resources if present
15
+ if attributes.resources
16
+ load attributes.resources.members, attributes.resources
17
+ end
14
18
 
15
19
  @links = attributes.links
16
20
  end
@@ -1,3 +1,3 @@
1
1
  class Frenetic
2
- VERSION = "0.0.2.alpha2"
2
+ VERSION = "0.0.2.alpha3"
3
3
  end
@@ -20,18 +20,18 @@ describe Frenetic::Resource do
20
20
 
21
21
  context "created from a HAL-JSON response" do
22
22
  let(:api_response) do
23
- Frenetic::HalJson::ResponseWrapper.new(
23
+ {
24
24
  '_links' => {
25
25
  '_self' => { '_href' => 'bar' }
26
26
  },
27
27
  'foo' => 1,
28
- 'bar' => 2,
29
- '_embedded' => {
30
- 'baz' => 'resource'
31
- }
32
- )
28
+ 'bar' => 2
29
+ }
30
+ end
31
+ let(:wrapped_response) do
32
+ Frenetic::HalJson::ResponseWrapper.new(api_response)
33
33
  end
34
- let(:resource_a) { Frenetic::Resource.new( api_response ) }
34
+ let(:resource_a) { Frenetic::Resource.new( wrapped_response ) }
35
35
  let(:resource_b) { Frenetic::Resource.new }
36
36
 
37
37
  before do
@@ -56,6 +56,23 @@ describe Frenetic::Resource do
56
56
  it { should_not respond_to(:bar) }
57
57
  its(:links) { should be_empty }
58
58
  end
59
+ context "with embedded resources" do
60
+ let(:api_response) do
61
+ {
62
+ '_links' => {
63
+ '_self' => { '_href' => 'bar' }
64
+ },
65
+ 'foo' => 1,
66
+ '_embedded' => {
67
+ 'baz' => 'resource'
68
+ }
69
+ }
70
+ end
71
+
72
+ subject { resource_a }
73
+
74
+ it { should respond_to(:baz) }
75
+ end
59
76
  end
60
77
 
61
78
  describe ".api_client" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frenetic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.alpha2
4
+ version: 0.0.2.alpha3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-04 00:00:00.000000000 Z
12
+ date: 2012-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
- requirement: &2152147580 !ruby/object:Gem::Requirement
16
+ requirement: &2156019160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152147580
24
+ version_requirements: *2156019160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday_middleware
27
- requirement: &2153580020 !ruby/object:Gem::Requirement
27
+ requirement: &2156098640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153580020
35
+ version_requirements: *2156098640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack-cache
38
- requirement: &2153579560 !ruby/object:Gem::Requirement
38
+ requirement: &2156098180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.1'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153579560
46
+ version_requirements: *2156098180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: addressable
49
- requirement: &2153579100 !ruby/object:Gem::Requirement
49
+ requirement: &2156097720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.2.8
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2153579100
57
+ version_requirements: *2156097720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: patron
60
- requirement: &2153578640 !ruby/object:Gem::Requirement
60
+ requirement: &2156097260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.4.18
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2153578640
68
+ version_requirements: *2156097260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-spork
71
- requirement: &2153578180 !ruby/object:Gem::Requirement
71
+ requirement: &2156096800 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.7.1
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153578180
79
+ version_requirements: *2156096800
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: guard-rspec
82
- requirement: &2153577720 !ruby/object:Gem::Requirement
82
+ requirement: &2156096340 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.7.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2153577720
90
+ version_requirements: *2156096340
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &2153577260 !ruby/object:Gem::Requirement
93
+ requirement: &2156095880 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 2.10.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2153577260
101
+ version_requirements: *2156095880
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: bourne
104
- requirement: &2153576800 !ruby/object:Gem::Requirement
104
+ requirement: &2156095420 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.1.2
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2153576800
112
+ version_requirements: *2156095420
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: webmock
115
- requirement: &2153576340 !ruby/object:Gem::Requirement
115
+ requirement: &2156094960 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 1.8.6
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2153576340
123
+ version_requirements: *2156094960
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: vcr
126
- requirement: &2153575880 !ruby/object:Gem::Requirement
126
+ requirement: &2156094500 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: 2.1.1
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2153575880
134
+ version_requirements: *2156094500
135
135
  description: An opinionated Ruby-based Hypermedia API client.
136
136
  email:
137
137
  - dlindahl@customink.com