odata4 0.7.0 → 0.8.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.
@@ -4,69 +4,92 @@ describe OData4::Service, vcr: {cassette_name: 'service_specs'} do
4
4
  let(:service_url) { 'http://services.odata.org/V4/OData/OData.svc' }
5
5
  let(:metadata_file) { 'spec/fixtures/files/metadata.xml' }
6
6
  let(:subject) { OData4::Service.open(service_url, name: 'ODataDemo', metadata_file: metadata_file) }
7
- let(:entity_types) { %w{Product FeaturedProduct ProductDetail Category Supplier Person Customer Employee PersonDetail Advertisement} }
8
- let(:entity_sets) { %w{Products ProductDetails Categories Suppliers Persons PersonDetails Advertisements} }
9
- let(:entity_set_types) { %w{Product ProductDetail Category Supplier Person PersonDetail Advertisement} }
10
- let(:complex_types) { %w{Address} }
11
- let(:enum_types) { %w{ProductStatus} }
12
- let(:associations) { %w{Product_Categories_Category_Products
13
- Product_Supplier_Supplier_Products
14
- Product_ProductDetail_ProductDetail_Product
15
- FeaturedProduct_Advertisement_Advertisement_FeaturedProduct
16
- Person_PersonDetail_PersonDetail_Person} }
17
7
 
18
8
  describe '.open' do
19
9
  it { expect(OData4::Service).to respond_to(:open) }
20
- end
10
+ it 'adds itself to OData4::ServiceRegistry on creation' do
11
+ expect(OData4::ServiceRegistry['ODataDemo']).to be_nil
12
+ expect(OData4::ServiceRegistry[service_url]).to be_nil
21
13
 
22
- it 'adds itself to OData4::ServiceRegistry on creation' do
23
- expect(OData4::ServiceRegistry['ODataDemo']).to be_nil
24
- expect(OData4::ServiceRegistry[service_url]).to be_nil
14
+ service = OData4::Service.open(service_url, name: 'ODataDemo')
25
15
 
26
- service = OData4::Service.open(service_url, name: 'ODataDemo')
16
+ expect(OData4::ServiceRegistry['ODataDemo']).to eq(service)
17
+ expect(OData4::ServiceRegistry[service_url]).to eq(service)
18
+ end
19
+ it 'registers custom types on creation' do
20
+ service = OData4::Service.open(service_url, name: 'ODataDemo')
27
21
 
28
- expect(OData4::ServiceRegistry['ODataDemo']).to eq(service)
29
- expect(OData4::ServiceRegistry[service_url]).to eq(service)
22
+ expect(OData4::PropertyRegistry['ODataDemo.Address']).to be_a(Class)
23
+ expect(OData4::PropertyRegistry['ODataDemo.ProductStatus']).to be_a(Class)
24
+ end
30
25
  end
31
26
 
32
- describe 'instance methods' do
27
+ describe '#service_url' do
33
28
  it { expect(subject).to respond_to(:service_url) }
34
- it { expect(subject).to respond_to(:entity_types) }
35
- it { expect(subject).to respond_to(:entity_sets) }
36
- it { expect(subject).to respond_to(:complex_types) }
37
- it { expect(subject).to respond_to(:enum_types) }
38
- it { expect(subject).to respond_to(:namespace) }
29
+ it { expect(subject.service_url).to eq(service_url) }
39
30
  end
40
31
 
41
- describe '#service_url' do
42
- it { expect(subject.service_url).to eq(service_url) }
32
+ describe '#schemas' do
33
+ it { expect(subject).to respond_to(:schemas) }
34
+ it { expect(subject.schemas.keys).to eq(['ODataDemo']) }
35
+ it { expect(subject.schemas.values).to all(be_a(OData4::Schema)) }
36
+ it {
37
+ subject.schemas.each do |namespace, schema|
38
+ expect(schema.namespace).to eq(namespace)
39
+ end
40
+ }
43
41
  end
44
42
 
45
43
  describe '#entity_types' do
44
+ it { expect(subject).to respond_to(:entity_types) }
46
45
  it { expect(subject.entity_types.size).to eq(10) }
47
- it { expect(subject.entity_types).to eq(entity_types) }
46
+ it { expect(subject.entity_types).to eq(%w[
47
+ ODataDemo.Product
48
+ ODataDemo.FeaturedProduct
49
+ ODataDemo.ProductDetail
50
+ ODataDemo.Category
51
+ ODataDemo.Supplier
52
+ ODataDemo.Person
53
+ ODataDemo.Customer
54
+ ODataDemo.Employee
55
+ ODataDemo.PersonDetail
56
+ ODataDemo.Advertisement
57
+ ]) }
48
58
  end
49
59
 
50
60
  describe '#entity_sets' do
61
+ it { expect(subject).to respond_to(:entity_sets) }
51
62
  it { expect(subject.entity_sets.size).to eq(7) }
52
- it { expect(subject.entity_sets.keys).to eq(entity_set_types) }
53
- it { expect(subject.entity_sets.values).to eq(entity_sets) }
63
+ it { expect(subject.entity_sets.keys).to eq(%w[
64
+ Products
65
+ ProductDetails
66
+ Categories
67
+ Suppliers
68
+ Persons
69
+ PersonDetails
70
+ Advertisements
71
+ ]) }
72
+ it { expect(subject.entity_sets.values).to eq(%w[
73
+ ODataDemo.Product
74
+ ODataDemo.ProductDetail
75
+ ODataDemo.Category
76
+ ODataDemo.Supplier
77
+ ODataDemo.Person
78
+ ODataDemo.PersonDetail
79
+ ODataDemo.Advertisement
80
+ ]) }
54
81
  end
55
82
 
56
83
  describe '#complex_types' do
84
+ it { expect(subject).to respond_to(:complex_types) }
57
85
  it { expect(subject.complex_types.size).to eq(1) }
58
- it { expect(subject.complex_types.keys).to eq(complex_types) }
86
+ it { expect(subject.complex_types.keys).to eq(['ODataDemo.Address']) }
59
87
  end
60
88
 
61
89
  describe '#enum_types' do
90
+ it { expect(subject).to respond_to(:enum_types) }
62
91
  it { expect(subject.enum_types.size).to eq(1) }
63
- it { expect(subject.enum_types.keys).to eq(enum_types)}
64
- end
65
-
66
- describe '#navigation_properties' do
67
- it { expect(subject).to respond_to(:navigation_properties) }
68
- it { expect(subject.navigation_properties['Product'].size).to eq(3) }
69
- it { expect(subject.navigation_properties['Product']['Categories']).to be_a(OData4::NavigationProperty) }
92
+ it { expect(subject.enum_types.keys).to eq(['ODataDemo.ProductStatus'])}
70
93
  end
71
94
 
72
95
  describe '#namespace' do
@@ -74,7 +97,34 @@ describe OData4::Service, vcr: {cassette_name: 'service_specs'} do
74
97
  end
75
98
 
76
99
  describe '#[]' do
77
- it { expect(subject['Products']).to be_a(OData4::EntitySet) }
100
+ let(:entity_sets) { subject.entity_sets.keys.map { |name| subject[name] } }
101
+ it { expect(entity_sets).to all(be_a(OData4::EntitySet)) }
78
102
  it { expect {subject['Nonexistant']}.to raise_error(ArgumentError) }
79
103
  end
104
+
105
+ describe '#get_property_type' do
106
+ it { expect(subject).to respond_to(:get_property_type) }
107
+ it { expect(subject.get_property_type('ODataDemo.Product', 'ID')).to eq('Edm.Int32') }
108
+ it { expect(subject.get_property_type('ODataDemo.Product', 'ProductStatus')).to eq('ODataDemo.ProductStatus') }
109
+ end
110
+
111
+ describe '#primary_key_for' do
112
+ it { expect(subject).to respond_to(:primary_key_for) }
113
+ it { expect(subject.primary_key_for('ODataDemo.Product')).to eq('ID') }
114
+ end
115
+
116
+ describe '#properties_for_entity' do
117
+ it { expect(subject).to respond_to(:properties_for_entity) }
118
+ it { expect(subject.properties_for_entity('ODataDemo.Product').keys).to eq(%w[
119
+ ID
120
+ Name
121
+ Description
122
+ ReleaseDate
123
+ DiscontinuedDate
124
+ Rating
125
+ Price
126
+ ProductStatus
127
+ ]) }
128
+ it { expect(subject.properties_for_entity('ODataDemo.Product').values).to all(be_a(OData4::Property)) }
129
+ end
80
130
  end
@@ -14,40 +14,40 @@ describe 'Usage examples', vcr: { cassette_name: 'usage_example_specs' } do
14
14
  end
15
15
 
16
16
  it 'lists entity types' do
17
- expect(service.entity_types).to eq([
18
- "Product",
19
- "FeaturedProduct",
20
- "ProductDetail",
21
- "Category",
22
- "Supplier",
23
- "Person",
24
- "Customer",
25
- "Employee",
26
- "PersonDetail",
27
- "Advertisement"
17
+ expect(service.entity_types).to eq(%w[
18
+ ODataDemo.Product
19
+ ODataDemo.FeaturedProduct
20
+ ODataDemo.ProductDetail
21
+ ODataDemo.Category
22
+ ODataDemo.Supplier
23
+ ODataDemo.Person
24
+ ODataDemo.Customer
25
+ ODataDemo.Employee
26
+ ODataDemo.PersonDetail
27
+ ODataDemo.Advertisement
28
28
  ])
29
29
  end
30
30
 
31
31
  it 'lists entity sets' do
32
32
  expect(service.entity_sets).to eq({
33
- "Product" => "Products",
34
- "ProductDetail" => "ProductDetails",
35
- "Category" => "Categories",
36
- "Supplier" => "Suppliers",
37
- "Person" => "Persons",
38
- "PersonDetail" => "PersonDetails",
39
- "Advertisement" => "Advertisements"
33
+ "Products" => "ODataDemo.Product",
34
+ "ProductDetails" => "ODataDemo.ProductDetail",
35
+ "Categories" => "ODataDemo.Category",
36
+ "Suppliers" => "ODataDemo.Supplier",
37
+ "Persons" => "ODataDemo.Person",
38
+ "PersonDetails" => "ODataDemo.PersonDetail",
39
+ "Advertisements" => "ODataDemo.Advertisement"
40
40
  })
41
41
  end
42
42
  end
43
43
 
44
44
  describe 'working with entity sets' do
45
45
  it 'accessing entity sets' do
46
- service.entity_sets.each do |entity_name, set_name|
47
- entity_set = service[set_name]
46
+ service.entity_sets.each do |entity_set_name, entity_name|
47
+ entity_set = service[entity_set_name]
48
48
 
49
49
  expect(entity_set).to be_a(OData4::EntitySet)
50
- expect(entity_set.name).to eq(set_name)
50
+ expect(entity_set.name).to eq(entity_set_name)
51
51
  expect(entity_set.type).to eq(entity_name)
52
52
  expect(entity_set.namespace).to eq(service.namespace)
53
53
  end
@@ -144,7 +144,7 @@ describe 'Usage examples', vcr: { cassette_name: 'usage_example_specs' } do
144
144
 
145
145
  batch.each do |entity|
146
146
  expect(entity).to be_a(OData4::Entity)
147
- expect(entity.type).to eq('Product')
147
+ expect(entity.type).to eq('ODataDemo.Product')
148
148
  end
149
149
  batch_count += 1
150
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odata4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Wagner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-27 00:00:00.000000000 Z
12
+ date: 2018-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -29,14 +29,14 @@ dependencies:
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
@@ -45,140 +45,140 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.15.1
48
+ version: '0.15'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 0.15.1
55
+ version: '0.15'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 3.7.0
62
+ version: '3.7'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 3.7.0
69
+ version: '3.7'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-autotest
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 1.0.0
76
+ version: '1.0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 1.0.0
83
+ version: '1.0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: autotest
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 4.4.6
90
+ version: '4.4'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 4.4.6
97
+ version: '4.4'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: vcr
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 4.0.0
104
+ version: '4.0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 4.0.0
111
+ version: '4.0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: timecop
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 0.9.1
118
+ version: '0.9'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 0.9.1
125
+ version: '0.9'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: equivalent-xml
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: 0.6.0
132
+ version: '0.6'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: 0.6.0
139
+ version: '0.6'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: nokogiri
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - "~>"
145
145
  - !ruby/object:Gem::Version
146
- version: 1.8.1
146
+ version: '1.8'
147
147
  type: :runtime
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: 1.8.1
153
+ version: '1.8'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: typhoeus
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: 1.3.0
160
+ version: '1.3'
161
161
  type: :runtime
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: 1.3.0
167
+ version: '1.3'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: andand
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - "~>"
173
173
  - !ruby/object:Gem::Version
174
- version: 1.3.3
174
+ version: '1.3'
175
175
  type: :runtime
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
- version: 1.3.3
181
+ version: '1.3'
182
182
  description: Provides a simple interface for working with OData V4 APIs.
183
183
  email:
184
184
  - christoph@wrstudios.com
@@ -203,6 +203,7 @@ files:
203
203
  - lib/odata4/complex_type.rb
204
204
  - lib/odata4/complex_type/property.rb
205
205
  - lib/odata4/entity.rb
206
+ - lib/odata4/entity_container.rb
206
207
  - lib/odata4/entity_set.rb
207
208
  - lib/odata4/enum_type.rb
208
209
  - lib/odata4/enum_type/property.rb
@@ -241,6 +242,7 @@ files:
241
242
  - lib/odata4/query/result/atom.rb
242
243
  - lib/odata4/query/result/json.rb
243
244
  - lib/odata4/railtie.rb
245
+ - lib/odata4/schema.rb
244
246
  - lib/odata4/service.rb
245
247
  - lib/odata4/service_registry.rb
246
248
  - lib/odata4/version.rb
@@ -267,6 +269,7 @@ files:
267
269
  - spec/fixtures/vcr_cassettes/usage_example_specs.yml
268
270
  - spec/odata4/complex_type_spec.rb
269
271
  - spec/odata4/entity/shared_examples.rb
272
+ - spec/odata4/entity_container_spec.rb
270
273
  - spec/odata4/entity_set_spec.rb
271
274
  - spec/odata4/entity_spec.rb
272
275
  - spec/odata4/enum_type_spec.rb
@@ -293,6 +296,7 @@ files:
293
296
  - spec/odata4/query/criteria_spec.rb
294
297
  - spec/odata4/query/result_spec.rb
295
298
  - spec/odata4/query_spec.rb
299
+ - spec/odata4/schema_spec.rb
296
300
  - spec/odata4/service_registry_spec.rb
297
301
  - spec/odata4/service_spec.rb
298
302
  - spec/odata4/usage_example_spec.rb
@@ -346,6 +350,7 @@ test_files:
346
350
  - spec/fixtures/vcr_cassettes/usage_example_specs.yml
347
351
  - spec/odata4/complex_type_spec.rb
348
352
  - spec/odata4/entity/shared_examples.rb
353
+ - spec/odata4/entity_container_spec.rb
349
354
  - spec/odata4/entity_set_spec.rb
350
355
  - spec/odata4/entity_spec.rb
351
356
  - spec/odata4/enum_type_spec.rb
@@ -372,6 +377,7 @@ test_files:
372
377
  - spec/odata4/query/criteria_spec.rb
373
378
  - spec/odata4/query/result_spec.rb
374
379
  - spec/odata4/query_spec.rb
380
+ - spec/odata4/schema_spec.rb
375
381
  - spec/odata4/service_registry_spec.rb
376
382
  - spec/odata4/service_spec.rb
377
383
  - spec/odata4/usage_example_spec.rb