ruby_odata 0.1.6 → 0.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +2 -0
  5. data/Guardfile +1 -1
  6. data/features/basic_auth.feature +13 -13
  7. data/features/cassettes/basic_auth_protected_resource.yml +22 -20
  8. data/features/cassettes/batch_request_additions.yml +26 -26
  9. data/features/cassettes/batch_request_deletes.yml +27 -27
  10. data/features/cassettes/batch_request_updates.yml +26 -26
  11. data/features/cassettes/clean_database_for_testing.yml +10 -10
  12. data/features/cassettes/cucumber_tags/basic_auth.yml +54 -163
  13. data/features/cassettes/cucumber_tags/batch_request.yml +229 -1118
  14. data/features/cassettes/cucumber_tags/complex_types.yml +81 -191
  15. data/features/cassettes/cucumber_tags/error_handling.yml +45 -33
  16. data/features/cassettes/cucumber_tags/query_builder.yml +555 -1248
  17. data/features/cassettes/cucumber_tags/service_manage.yml +216 -591
  18. data/features/cassettes/cucumber_tags/service_methods.yml +137 -412
  19. data/features/cassettes/cucumber_tags/ssl.yml +121 -117
  20. data/features/cassettes/cucumber_tags/type_conversion.yml +104 -170
  21. data/features/cassettes/service_manage_additions.yml +26 -28
  22. data/features/cassettes/service_manage_deletions.yml +21 -21
  23. data/features/cassettes/service_manage_deletions_2.yml +21 -21
  24. data/features/cassettes/unsecured_metadata.yml +14 -14
  25. data/features/service.feature +37 -37
  26. data/features/service_methods.feature +38 -38
  27. data/features/step_definitions/pickle_steps.rb +5 -5
  28. data/features/step_definitions/service_steps.rb +26 -26
  29. data/features/support/hooks.rb +3 -2
  30. data/features/support/vcr.rb +13 -13
  31. data/lib/ruby_odata.rb +4 -1
  32. data/lib/ruby_odata/association.rb +15 -8
  33. data/lib/ruby_odata/class_builder.rb +5 -1
  34. data/lib/ruby_odata/query_builder.rb +171 -173
  35. data/lib/ruby_odata/resource.rb +153 -0
  36. data/lib/ruby_odata/service.rb +30 -30
  37. data/lib/ruby_odata/version.rb +1 -1
  38. data/ruby_odata.gemspec +48 -43
  39. data/spec/association_spec.rb +15 -11
  40. data/spec/fixtures/decimal/metadata.xml +1 -0
  41. data/spec/fixtures/v4/edmx_metadata.xml +145 -0
  42. data/spec/fixtures/v4/result_categories.xml +0 -0
  43. data/spec/revised_service_spec.rb +16 -11
  44. data/spec/service_spec.rb +149 -114
  45. data/spec/service_v4_spec.rb +102 -0
  46. data/spec/spec_helper.rb +6 -1
  47. metadata +109 -32
  48. data/features/cassettes/cucumber_tags/service.yml +0 -234
@@ -0,0 +1,102 @@
1
+ require 'spec_helper'
2
+
3
+ describe "V4 Service" do
4
+ before(:all) do
5
+ stub_request(:get, /http:\/\/test\.com\/test\.svc\/\$metadata(?:\?.+)?/).
6
+ with(:headers => DEFAULT_HEADERS).
7
+ to_return(:status => 200, :body => File.new(File.expand_path("../fixtures/v4/edmx_metadata.xml", __FILE__)), :headers => {})
8
+
9
+ stub_request(:get, "http://test.com/test.svc/Categories").
10
+ to_return(:status => 200, :body => File.new(File.expand_path("../fixtures/v4/result_categories.xml", __FILE__)), :headers => {})
11
+
12
+ @service = OData::Service.new "http://test.com/test.svc"
13
+ end
14
+ subject { @service }
15
+
16
+ context "methods" do
17
+ it { should respond_to :update_object }
18
+ it { should respond_to :delete_object }
19
+ it { should respond_to :save_changes }
20
+ it { should respond_to :load_property }
21
+ it { should respond_to :add_link }
22
+ it { should respond_to :execute }
23
+ it { should respond_to :partial? }
24
+ it { should respond_to :next }
25
+ it { should respond_to :classes }
26
+ it { should respond_to :class_metadata }
27
+ it { should respond_to :collections }
28
+ it { should respond_to :options }
29
+ it { should respond_to :function_imports }
30
+
31
+ context "after parsing metadata" do
32
+ it { should respond_to :Products }
33
+ it { should respond_to :Categories }
34
+ it { should respond_to :AddToProducts }
35
+ it { should respond_to :AddToCategories }
36
+ end
37
+ end
38
+
39
+ context "collections method" do
40
+ subject { @service.collections }
41
+ it { should include 'Products' }
42
+ it { should include 'Categories' }
43
+ it "should expose the edmx type of objects" do
44
+ subject['Products'][:edmx_type].should eq 'ODataDemo.Product'
45
+ subject['Categories'][:edmx_type].should eq 'ODataDemo.Category'
46
+ end
47
+ it "should expose the local model type" do
48
+ subject['Products'][:type].should eq Product
49
+ subject['Categories'][:type].should eq Category
50
+ end
51
+ end
52
+
53
+ context "class metadata" do
54
+ subject { @service.class_metadata }
55
+ it { should_not be_empty}
56
+ it { should have_key 'Product' }
57
+ it { should have_key 'Category' }
58
+
59
+ context "should have keys for each property" do
60
+ subject { @service.class_metadata['Category'] }
61
+ it { should have_key 'ID' }
62
+ it { should have_key 'Name' }
63
+ it { should have_key 'Products' }
64
+ it "should return a PropertyMetadata object for each property" do
65
+ subject['ID'].should be_an OData::PropertyMetadata
66
+ subject['Name'].should be_an OData::PropertyMetadata
67
+ subject['Products'].should be_an OData::PropertyMetadata
68
+ end
69
+ it "should have correct PropertyMetadata for Category.Id" do
70
+ meta = subject['ID']
71
+ meta.name.should eq 'ID'
72
+ meta.type.should eq 'Edm.Int32'
73
+ meta.nullable.should eq false
74
+ meta.fc_target_path.should be_nil
75
+ meta.fc_keep_in_content.should be_nil
76
+ meta.nav_prop.should eq false
77
+ meta.is_key.should eq true
78
+ end
79
+ it "should have correct PropertyMetadata for Category.Name" do
80
+ meta = subject['Name']
81
+ meta.name.should eq 'Name'
82
+ meta.type.should eq 'Edm.String'
83
+ meta.nullable.should eq false
84
+ meta.fc_target_path.should be_nil
85
+ meta.fc_keep_in_content.should be_nil
86
+ meta.nav_prop.should eq false
87
+ meta.is_key.should eq false
88
+ end
89
+ it "should have correct PropertyMetadata for Category.Products" do
90
+ meta = subject['Products']
91
+ meta.name.should eq 'Products'
92
+ meta.type.should eq 'Collection(ODataDemo.Product)'
93
+ meta.nullable.should eq true
94
+ meta.fc_target_path.should be_nil
95
+ meta.fc_keep_in_content.should be_nil
96
+ meta.nav_prop.should eq true
97
+ meta.association.should_not be_nil
98
+ meta.is_key.should eq false
99
+ end
100
+ end
101
+ end
102
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'ruby_odata'
2
2
  require 'webmock/rspec'
3
3
  require 'simplecov'
4
+ require 'rspec/its'
4
5
  # require 'coveralls'
5
6
  # Coveralls.wear_merged!
6
7
 
7
- Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
8
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
9
+
10
+ WebMock.disable_net_connect!(allow_localhost: true)
11
+ DEFAULT_HEADERS = {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip,deflate'}
12
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_odata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien White
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: i18n
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.0
33
+ version: 0.7.0
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
- version: 0.6.0
40
+ version: 0.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,19 +53,47 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: rest-client
56
+ name: excon
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.45.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.45.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 1.5.1
75
+ version: '0'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 1.5.1
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.1
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: nokogiri
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -84,14 +112,14 @@ dependencies:
84
112
  name: rake
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - '='
115
+ - - ">="
88
116
  - !ruby/object:Gem::Version
89
117
  version: 0.9.2
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - '='
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
124
  version: 0.9.2
97
125
  - !ruby/object:Gem::Dependency
@@ -100,42 +128,56 @@ dependencies:
100
128
  requirements:
101
129
  - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: 2.11.0
131
+ version: 3.2.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 3.2.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec-its
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 1.2.0
104
146
  type: :development
105
147
  prerelease: false
106
148
  version_requirements: !ruby/object:Gem::Requirement
107
149
  requirements:
108
150
  - - "~>"
109
151
  - !ruby/object:Gem::Version
110
- version: 2.11.0
152
+ version: 1.2.0
111
153
  - !ruby/object:Gem::Dependency
112
154
  name: cucumber
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
157
  - - "~>"
116
158
  - !ruby/object:Gem::Version
117
- version: 1.2.1
159
+ version: 2.0.0
118
160
  type: :development
119
161
  prerelease: false
120
162
  version_requirements: !ruby/object:Gem::Requirement
121
163
  requirements:
122
164
  - - "~>"
123
165
  - !ruby/object:Gem::Version
124
- version: 1.2.1
166
+ version: 2.0.0
125
167
  - !ruby/object:Gem::Dependency
126
168
  name: pickle
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - "~>"
130
172
  - !ruby/object:Gem::Version
131
- version: 0.4.11
173
+ version: 0.5.1
132
174
  type: :development
133
175
  prerelease: false
134
176
  version_requirements: !ruby/object:Gem::Requirement
135
177
  requirements:
136
178
  - - "~>"
137
179
  - !ruby/object:Gem::Version
138
- version: 0.4.11
180
+ version: 0.5.1
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: machinist
141
183
  requirement: !ruby/object:Gem::Requirement
@@ -156,70 +198,70 @@ dependencies:
156
198
  requirements:
157
199
  - - "~>"
158
200
  - !ruby/object:Gem::Version
159
- version: 1.11.0
201
+ version: 1.21.0
160
202
  type: :development
161
203
  prerelease: false
162
204
  version_requirements: !ruby/object:Gem::Requirement
163
205
  requirements:
164
206
  - - "~>"
165
207
  - !ruby/object:Gem::Version
166
- version: 1.11.0
208
+ version: 1.21.0
167
209
  - !ruby/object:Gem::Dependency
168
210
  name: guard
169
211
  requirement: !ruby/object:Gem::Requirement
170
212
  requirements:
171
213
  - - "~>"
172
214
  - !ruby/object:Gem::Version
173
- version: 1.3.0
215
+ version: 2.12.5
174
216
  type: :development
175
217
  prerelease: false
176
218
  version_requirements: !ruby/object:Gem::Requirement
177
219
  requirements:
178
220
  - - "~>"
179
221
  - !ruby/object:Gem::Version
180
- version: 1.3.0
222
+ version: 2.12.5
181
223
  - !ruby/object:Gem::Dependency
182
224
  name: guard-rspec
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
227
  - - "~>"
186
228
  - !ruby/object:Gem::Version
187
- version: 1.2.1
229
+ version: 4.5.0
188
230
  type: :development
189
231
  prerelease: false
190
232
  version_requirements: !ruby/object:Gem::Requirement
191
233
  requirements:
192
234
  - - "~>"
193
235
  - !ruby/object:Gem::Version
194
- version: 1.2.1
236
+ version: 4.5.0
195
237
  - !ruby/object:Gem::Dependency
196
238
  name: guard-cucumber
197
239
  requirement: !ruby/object:Gem::Requirement
198
240
  requirements:
199
241
  - - "~>"
200
242
  - !ruby/object:Gem::Version
201
- version: 1.2.0
243
+ version: 1.6.0
202
244
  type: :development
203
245
  prerelease: false
204
246
  version_requirements: !ruby/object:Gem::Requirement
205
247
  requirements:
206
248
  - - "~>"
207
249
  - !ruby/object:Gem::Version
208
- version: 1.2.0
250
+ version: 1.6.0
209
251
  - !ruby/object:Gem::Dependency
210
252
  name: vcr
211
253
  requirement: !ruby/object:Gem::Requirement
212
254
  requirements:
213
255
  - - "~>"
214
256
  - !ruby/object:Gem::Version
215
- version: 2.5.0
257
+ version: 2.9.3
216
258
  type: :development
217
259
  prerelease: false
218
260
  version_requirements: !ruby/object:Gem::Requirement
219
261
  requirements:
220
262
  - - "~>"
221
263
  - !ruby/object:Gem::Version
222
- version: 2.5.0
264
+ version: 2.9.3
223
265
  - !ruby/object:Gem::Dependency
224
266
  name: simplecov
225
267
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +290,34 @@ dependencies:
248
290
  - - "~>"
249
291
  - !ruby/object:Gem::Version
250
292
  version: 0.6.7
293
+ - !ruby/object:Gem::Dependency
294
+ name: pry
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: pry-nav
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ type: :development
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ version: '0'
251
321
  description: An OData Client Library for Ruby. Use this to interact with OData services
252
322
  email:
253
323
  - damien.white@visoftinc.com
@@ -280,7 +350,6 @@ files:
280
350
  - features/cassettes/cucumber_tags/complex_types.yml
281
351
  - features/cassettes/cucumber_tags/error_handling.yml
282
352
  - features/cassettes/cucumber_tags/query_builder.yml
283
- - features/cassettes/cucumber_tags/service.yml
284
353
  - features/cassettes/cucumber_tags/service_manage.yml
285
354
  - features/cassettes/cucumber_tags/service_methods.yml
286
355
  - features/cassettes/cucumber_tags/ssl.yml
@@ -314,11 +383,13 @@ files:
314
383
  - lib/ruby_odata/operation.rb
315
384
  - lib/ruby_odata/property_metadata.rb
316
385
  - lib/ruby_odata/query_builder.rb
386
+ - lib/ruby_odata/resource.rb
317
387
  - lib/ruby_odata/service.rb
318
388
  - lib/ruby_odata/version.rb
319
389
  - ruby_odata.gemspec
320
390
  - spec/association_spec.rb
321
391
  - spec/class_builder_spec.rb
392
+ - spec/fixtures/decimal/metadata.xml
322
393
  - spec/fixtures/edmx_empty.xml
323
394
  - spec/fixtures/edmx_lowercase.xml
324
395
  - spec/fixtures/error_without_message.xml
@@ -358,10 +429,13 @@ files:
358
429
  - spec/fixtures/sample_service/result_single_product_not_found.xml
359
430
  - spec/fixtures/sap/edmx_sap_demo_flight.xml
360
431
  - spec/fixtures/sap/result_sap_demo_flight_missing_category.xml
432
+ - spec/fixtures/v4/edmx_metadata.xml
433
+ - spec/fixtures/v4/result_categories.xml
361
434
  - spec/property_metadata_spec.rb
362
435
  - spec/query_builder_spec.rb
363
436
  - spec/revised_service_spec.rb
364
437
  - spec/service_spec.rb
438
+ - spec/service_v4_spec.rb
365
439
  - spec/spec_helper.rb
366
440
  - spec/support/describe_private.rb
367
441
  - spec/support/element_helpers.rb
@@ -489,12 +563,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
489
563
  version: 1.9.3
490
564
  required_rubygems_version: !ruby/object:Gem::Requirement
491
565
  requirements:
492
- - - ">="
566
+ - - ">"
493
567
  - !ruby/object:Gem::Version
494
- version: '0'
568
+ version: 1.3.1
495
569
  requirements: []
496
570
  rubyforge_project: ruby-odata
497
- rubygems_version: 2.2.2
571
+ rubygems_version: 2.4.8
498
572
  signing_key:
499
573
  specification_version: 4
500
574
  summary: Ruby consumer of OData services.
@@ -511,7 +585,6 @@ test_files:
511
585
  - features/cassettes/cucumber_tags/complex_types.yml
512
586
  - features/cassettes/cucumber_tags/error_handling.yml
513
587
  - features/cassettes/cucumber_tags/query_builder.yml
514
- - features/cassettes/cucumber_tags/service.yml
515
588
  - features/cassettes/cucumber_tags/service_manage.yml
516
589
  - features/cassettes/cucumber_tags/service_methods.yml
517
590
  - features/cassettes/cucumber_tags/ssl.yml
@@ -538,6 +611,7 @@ test_files:
538
611
  - features/type_conversion.feature
539
612
  - spec/association_spec.rb
540
613
  - spec/class_builder_spec.rb
614
+ - spec/fixtures/decimal/metadata.xml
541
615
  - spec/fixtures/edmx_empty.xml
542
616
  - spec/fixtures/edmx_lowercase.xml
543
617
  - spec/fixtures/error_without_message.xml
@@ -577,10 +651,13 @@ test_files:
577
651
  - spec/fixtures/sample_service/result_single_product_not_found.xml
578
652
  - spec/fixtures/sap/edmx_sap_demo_flight.xml
579
653
  - spec/fixtures/sap/result_sap_demo_flight_missing_category.xml
654
+ - spec/fixtures/v4/edmx_metadata.xml
655
+ - spec/fixtures/v4/result_categories.xml
580
656
  - spec/property_metadata_spec.rb
581
657
  - spec/query_builder_spec.rb
582
658
  - spec/revised_service_spec.rb
583
659
  - spec/service_spec.rb
660
+ - spec/service_v4_spec.rb
584
661
  - spec/spec_helper.rb
585
662
  - spec/support/describe_private.rb
586
663
  - spec/support/element_helpers.rb