ruby_odata 0.0.10 → 0.1.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.
Files changed (173) hide show
  1. data/.gitignore +9 -3
  2. data/.travis.yml +4 -0
  3. data/CHANGELOG.rdoc +18 -1
  4. data/README.rdoc +77 -19
  5. data/config/cucumber.yml +4 -3
  6. data/features/basic_auth.feature +5 -7
  7. data/features/batch_request.feature +11 -11
  8. data/features/complex_types.feature +11 -11
  9. data/features/query_builder.feature +27 -18
  10. data/features/service.feature +8 -8
  11. data/features/service_manage.feature +27 -12
  12. data/features/service_methods.feature +37 -0
  13. data/features/ssl.feature +4 -4
  14. data/features/step_definitions/pickle_steps.rb +100 -0
  15. data/features/step_definitions/service_steps.rb +99 -65
  16. data/features/support/constants.rb +3 -0
  17. data/features/support/custom_helpers.rb +54 -0
  18. data/features/support/env.rb +0 -10
  19. data/features/support/hooks.rb +1 -1
  20. data/features/support/pickle.rb +82 -0
  21. data/features/type_conversion.feature +10 -10
  22. data/lib/ruby_odata.rb +4 -1
  23. data/lib/ruby_odata/association.rb +36 -0
  24. data/lib/ruby_odata/class_builder.rb +96 -16
  25. data/lib/ruby_odata/helpers.rb +10 -0
  26. data/lib/ruby_odata/operation.rb +7 -5
  27. data/lib/ruby_odata/property_metadata.rb +11 -6
  28. data/lib/ruby_odata/query_builder.rb +20 -1
  29. data/lib/ruby_odata/service.rb +407 -94
  30. data/lib/ruby_odata/version.rb +1 -1
  31. data/ruby_odata.gemspec +2 -0
  32. data/spec/association_spec.rb +48 -0
  33. data/spec/class_builder_spec.rb +11 -2
  34. data/spec/fixtures/inheritance/edmx_pluralsight.xml +111 -0
  35. data/spec/fixtures/inheritance/result_pluralsight_courses.xml +229 -0
  36. data/spec/fixtures/links/result_links_query.xml +6 -0
  37. data/spec/fixtures/partial/partial_feed_metadata.xml +25 -0
  38. data/spec/fixtures/partial/partial_feed_part_1.xml +42 -0
  39. data/spec/fixtures/partial/partial_feed_part_2.xml +42 -0
  40. data/spec/fixtures/partial/partial_feed_part_3.xml +40 -0
  41. data/spec/fixtures/sample_service/edmx_categories_products.xml +1 -0
  42. data/spec/fixtures/sample_service/result_category_names.xml +5 -0
  43. data/spec/fixtures/sample_service/result_entity_category_web_get.xml +29 -0
  44. data/spec/fixtures/sample_service/result_entity_single_category_web_get.xml +23 -0
  45. data/spec/fixtures/sample_service/result_first_category_id.xml +2 -0
  46. data/spec/fixtures/sample_service/result_multiple_category_products.xml +57 -0
  47. data/spec/fixtures/sample_service/result_single_category.xml +18 -0
  48. data/spec/fixtures/sample_service/result_single_product.xml +26 -0
  49. data/spec/fixtures/sample_service/result_single_product_not_found.xml +4 -0
  50. data/spec/fixtures/sap/edmx_sap_demo_flight.xml +62 -58
  51. data/spec/property_metadata_spec.rb +9 -2
  52. data/spec/query_builder_spec.rb +11 -0
  53. data/spec/revised_service_spec.rb +197 -0
  54. data/spec/service_spec.rb +463 -4
  55. data/test/RubyODataService/RubyODataService.sln +20 -0
  56. data/test/RubyODataService/RubyODataService/App_Start/EntityFramework.SqlServerCompact.cs +12 -0
  57. data/test/RubyODataService/RubyODataService/BasicAuth/RubyOData.svc +3 -0
  58. data/test/RubyODataService/RubyODataService/BasicAuth/RubyOData.svc.cs +107 -0
  59. data/test/RubyODataService/RubyODataService/Global.asax +1 -0
  60. data/test/RubyODataService/RubyODataService/Global.asax.cs +49 -0
  61. data/test/RubyODataService/RubyODataService/Models/AuditFields.cs +16 -0
  62. data/test/RubyODataService/RubyODataService/Models/Category.cs +16 -0
  63. data/test/RubyODataService/RubyODataService/Models/Product.cs +20 -0
  64. data/test/RubyODataService/RubyODataService/Properties/AssemblyInfo.cs +35 -0
  65. data/test/RubyODataService/RubyODataService/RubyOData.svc +3 -0
  66. data/test/RubyODataService/RubyODataService/RubyOData.svc.cs +57 -0
  67. data/test/RubyODataService/RubyODataService/RubyODataContext.cs +16 -0
  68. data/test/RubyODataService/RubyODataService/RubyODataService.csproj +159 -0
  69. data/test/RubyODataService/RubyODataService/RubyODataService.csproj.user +31 -0
  70. data/test/RubyODataService/RubyODataService/Web.Debug.config +30 -0
  71. data/test/RubyODataService/RubyODataService/Web.Release.config +31 -0
  72. data/test/RubyODataService/RubyODataService/Web.config +27 -0
  73. data/test/RubyODataService/RubyODataService/bin/EntityFramework.dll +0 -0
  74. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Edm.dll +0 -0
  75. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.OData.dll +0 -0
  76. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Services.Client.dll +0 -0
  77. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Services.dll +0 -0
  78. data/test/RubyODataService/RubyODataService/bin/Microsoft.Data.Spatial.dll +0 -0
  79. data/test/RubyODataService/RubyODataService/bin/RubyODataService.dll +0 -0
  80. data/test/RubyODataService/RubyODataService/bin/System.Data.SqlServerCe.Entity.dll +0 -0
  81. data/test/RubyODataService/RubyODataService/bin/System.Data.SqlServerCe.dll +0 -0
  82. data/test/RubyODataService/RubyODataService/bin/System.Spatial.dll +0 -0
  83. data/test/RubyODataService/RubyODataService/bin/WebActivator.dll +0 -0
  84. data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  85. data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  86. data/test/RubyODataService/RubyODataService/bin/amd64/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  87. data/test/RubyODataService/RubyODataService/bin/amd64/sqlcecompact40.dll +0 -0
  88. data/test/RubyODataService/RubyODataService/bin/amd64/sqlceer40EN.dll +0 -0
  89. data/test/RubyODataService/RubyODataService/bin/amd64/sqlceme40.dll +0 -0
  90. data/test/RubyODataService/RubyODataService/bin/amd64/sqlceqp40.dll +0 -0
  91. data/test/RubyODataService/RubyODataService/bin/amd64/sqlcese40.dll +0 -0
  92. data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  93. data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  94. data/test/RubyODataService/RubyODataService/bin/x86/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  95. data/test/RubyODataService/RubyODataService/bin/x86/sqlcecompact40.dll +0 -0
  96. data/test/RubyODataService/RubyODataService/bin/x86/sqlceer40EN.dll +0 -0
  97. data/test/RubyODataService/RubyODataService/bin/x86/sqlceme40.dll +0 -0
  98. data/test/RubyODataService/RubyODataService/bin/x86/sqlceqp40.dll +0 -0
  99. data/test/RubyODataService/RubyODataService/bin/x86/sqlcese40.dll +0 -0
  100. data/test/RubyODataService/RubyODataService/packages.config +7 -0
  101. data/test/RubyODataService/packages/EntityFramework.4.2.0.0/EntityFramework.4.2.0.0.nupkg +0 -0
  102. data/test/RubyODataService/packages/EntityFramework.4.2.0.0/lib/net40/EntityFramework.dll +0 -0
  103. data/test/RubyODataService/packages/EntityFramework.4.2.0.0/lib/net40/EntityFramework.xml +13488 -0
  104. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/Content/App_Start/EntityFramework.SqlServerCompact.cs.pp +12 -0
  105. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/EULA_ENU.rtf +969 -0
  106. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/EntityFramework.SqlServerCompact.4.1.8482.2.nupkg +0 -0
  107. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/lib/System.Data.SqlServerCe.Entity.dll +0 -0
  108. data/test/RubyODataService/packages/EntityFramework.SqlServerCompact.4.1.8482.2/tools/install.ps1 +3 -0
  109. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Content/web.config.transform +8 -0
  110. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  111. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  112. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  113. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlcecompact40.dll +0 -0
  114. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceer40EN.dll +0 -0
  115. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceme40.dll +0 -0
  116. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlceqp40.dll +0 -0
  117. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/amd64/sqlcese40.dll +0 -0
  118. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest +6 -0
  119. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/README_ENU.txt +0 -0
  120. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/Microsoft.VC90.CRT/msvcr90.dll +0 -0
  121. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlcecompact40.dll +0 -0
  122. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceer40EN.dll +0 -0
  123. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceme40.dll +0 -0
  124. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlceqp40.dll +0 -0
  125. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/NativeBinaries/x86/sqlcese40.dll +0 -0
  126. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/SQLCE_EULA_ENU.rtf +778 -0
  127. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/SqlServerCompact.4.0.8482.1.nupkg +0 -0
  128. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/GetSqlCEPostBuildCmd.ps1 +12 -0
  129. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/install.ps1 +11 -0
  130. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/Tools/uninstall.ps1 +9 -0
  131. data/test/RubyODataService/packages/SqlServerCompact.4.0.8482.1/lib/System.Data.SqlServerCe.dll +0 -0
  132. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/DataSvcUtil.exe +0 -0
  133. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/License.rtf +708 -0
  134. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Edm.dll +0 -0
  135. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Edm.xml +4150 -0
  136. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.OData.dll +0 -0
  137. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.OData.xml +1969 -0
  138. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Client.dll +0 -0
  139. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Client.xml +1442 -0
  140. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Design.dll +0 -0
  141. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.Design.xml +191 -0
  142. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.dll +0 -0
  143. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Services.xml +2559 -0
  144. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Spatial.dll +0 -0
  145. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.Data.Spatial.xml +15 -0
  146. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/Microsoft.VsDesigner.DataServices.Adapter.dll +0 -0
  147. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/README.txt +6 -0
  148. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/System.Spatial.dll +0 -0
  149. data/test/RubyODataService/packages/WCF DataServices October 2011 CTP/System.Spatial.xml +2276 -0
  150. data/test/RubyODataService/packages/WebActivator.1.0.0.0/WebActivator.1.0.0.0.nupkg +0 -0
  151. data/test/RubyODataService/packages/WebActivator.1.0.0.0/lib/WebActivator.dll +0 -0
  152. data/test/RubyODataService/packages/repositories.config +4 -0
  153. data/test/applicationhost.config.template +2 -2
  154. data/test/blueprints.rb +5 -4
  155. data/test/iisExpress x64.bat b/data/test/iisExpress → x64.bat +0 -0
  156. data/test/iisExpress x86.bat b/data/test/iisExpress → x86.bat +0 -0
  157. data/test/setpath.rb +13 -3
  158. data/test/usage_samples/querying.rb +45 -0
  159. data/test/usage_samples/reflection.rb +16 -0
  160. data/test/usage_samples/sample_data.rb +30 -0
  161. metadata +327 -36
  162. data/test/Cassini x64.bat +0 -1
  163. data/test/Cassini x86.bat +0 -1
  164. data/test/SampleService/App_Code/AuditFields.cs +0 -13
  165. data/test/SampleService/App_Code/Entities.cs +0 -145
  166. data/test/SampleService/App_Code/Model.Designer.cs +0 -578
  167. data/test/SampleService/App_Code/Model.edmx +0 -157
  168. data/test/SampleService/App_Code/ModelContainerExtended.cs +0 -32
  169. data/test/SampleService/App_Data/_TestDB.mdf +0 -0
  170. data/test/SampleService/App_Data/_TestDB_Log.ldf +0 -0
  171. data/test/SampleService/BasicAuth/Entities.svc +0 -1
  172. data/test/SampleService/Entities.svc +0 -1
  173. data/test/SampleService/web.config +0 -37
@@ -4,7 +4,7 @@ Feature: Service Should Generate a Proxy
4
4
  I want to be able to access data
5
5
 
6
6
  Background:
7
- Given a sample HTTP ODataService exists
7
+ Given a HTTP ODataService exists
8
8
  And blueprints exist for the service
9
9
 
10
10
  Scenario: Service should respond to valid collections
@@ -21,29 +21,29 @@ Scenario: Access an entity by ID should return the entity type
21
21
  And I save changes
22
22
  And I call "Categories" on the service with args: "1"
23
23
  When I run the query
24
- Then the result should be of type "Category"
24
+ Then the first result should be of type "Category"
25
25
 
26
26
  Scenario: Entity should have the correct accessors
27
27
  Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
28
28
  And I save changes
29
29
  And I call "Categories" on the service with args: "1"
30
30
  When I run the query
31
- Then the result should have a method: "Id"
32
- And the result should have a method: "Name"
31
+ Then the first result should have a method: "Id"
32
+ And the first result should have a method: "Name"
33
33
 
34
34
  Scenario: Entity should fill values
35
35
  Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
36
36
  And I save changes
37
37
  And I call "Categories" on the service with args: "1"
38
38
  When I run the query
39
- Then the method "Id" on the result should equal: "1"
40
- And the method "Name" on the result should equal: "Test Category"
39
+ Then the method "Id" on the first result should equal: "1"
40
+ And the method "Name" on the first result should equal: "Test Category"
41
41
 
42
42
  Scenario: Navigation Properties should be included in results
43
43
  Given I call "AddToProducts" on the service with a new "Product" object
44
44
  And I save changes
45
45
  And I call "Products" on the service with args: "1"
46
46
  When I run the query
47
- Then the result should have a method: "Category"
48
- And the method "Category" on the result should be nil
47
+ Then the first result should have a method: "Category"
48
+ And the method "Category" on the first result should be nil
49
49
 
@@ -4,20 +4,20 @@ Feature: Service management
4
4
  I want to be able to add, edit, and delete entities
5
5
 
6
6
  Background:
7
- Given an ODataService exists with uri: "http://localhost:8989/SampleService/Entities.svc"
7
+ Given a HTTP ODataService exists
8
8
  And blueprints exist for the service
9
9
 
10
10
  Scenario: Service should respond to AddToEntityName for adding objects
11
11
  Given I call "AddToProducts" on the service with a new "Product" object with Name: "Sample Product"
12
12
  When I save changes
13
- Then the save result should be of type "Product"
14
- And the method "Name" on the save result should equal: "Sample Product"
13
+ Then the first save result should be of type "Product"
14
+ And the method "Name" on the first save result should equal: "Sample Product"
15
15
 
16
16
  Scenario: Service should allow for deletes
17
17
  Given I call "AddToProducts" on the service with a new "Product" object
18
18
  When I save changes
19
- Then the save result should be of type "Product"
20
- When I call "delete_object" on the service with the last save result
19
+ Then the first save result should be of type "Product"
20
+ When I call "delete_object" on the service with the first last save result
21
21
  And I save changes
22
22
  Then the save result should equal: "true"
23
23
  And no "Products" should exist
@@ -30,15 +30,15 @@ Scenario: Entities should be able to be updated
30
30
  When I save changes
31
31
  And I call "Products" on the service with args: "1"
32
32
  And I run the query
33
- Then the method "Name" on the result should equal: "Test Product"
34
- When I set "Name" on the result to "Changed Test Product"
35
- Then the method "Name" on the result should equal: "Changed Test Product"
36
- And I call "update_object" on the service with the last query result
33
+ Then the method "Name" on the first result should equal: "Test Product"
34
+ When I set "Name" on the first result to "Changed Test Product"
35
+ Then the method "Name" on the first result should equal: "Changed Test Product"
36
+ And I call "update_object" on the service with the first last query result
37
37
  And I save changes
38
38
  Then the save result should equal: "true"
39
39
  When I call "Products" on the service with args: "1"
40
40
  And I run the query
41
- Then the method "Name" on the result should equal: "Changed Test Product"
41
+ Then the method "Name" on the first result should equal: "Changed Test Product"
42
42
 
43
43
  Scenario: Untracked entities shouldn't be able to be updated
44
44
  Given I call "update_object" on the service with a new "Product" object it should throw an exception with message "You cannot update a non-tracked entity"
@@ -46,9 +46,24 @@ Scenario: Untracked entities shouldn't be able to be updated
46
46
  Scenario: Related entities shouldn't be recreated on a child add
47
47
  Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
48
48
  And I save changes
49
- And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave"
49
+ And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave.first"
50
50
  And I save changes
51
51
  And I call "Products" on the service with args: "1"
52
52
  And I expand the query to include "Category"
53
53
  When I run the query
54
- Then the method "Id" on the result's method "Category" should equal: "1"
54
+ Then the method "Id" on the first result's method "Category" should equal: "1"
55
+
56
+ Scenario: Entities should be able to be linked together
57
+ Given a category: "cat1" exists
58
+ And a product: "prod1" exists
59
+ When I add a link between category: "cat1" and product: "prod1" on "Products"
60
+ And I save changes
61
+ Then the product: "prod1" should be one of category: "cat1"'s Products
62
+
63
+ Scenario: Entities should be able to be linked together on a batch save
64
+ Given a category: "cat1" exists
65
+ And a product: "prod1" exists
66
+ When I add a link between category: "cat1" and product: "prod1" on "Products"
67
+ And I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
68
+ And I save changes
69
+ Then the product: "prod1" should be one of category: "cat1"'s Products
@@ -0,0 +1,37 @@
1
+ Feature: Service methods
2
+ In order to use a WCF Data Service more efficiently
3
+ As a consumer
4
+ I want to be able to utilize custom WCF DS methods
5
+
6
+ Background:
7
+ Given a HTTP ODataService exists
8
+ And blueprints exist for the service
9
+
10
+
11
+ Scenario: A custom web get (no parameters) that returns an entity
12
+ Given a category exists
13
+ And I call the service method "EntityCategoryWebGet"
14
+ Then the first result should be of type "Category"
15
+
16
+ Scenario: A custom web get (with parameters) that returns a single entity
17
+ Given a category: "cat1" exists with Id: 1
18
+ When I call the service method "EntitySingleCategoryWebGet" with 1
19
+ Then the result should be of type "Category"
20
+ And the method "Id" on the result should equal: "1"
21
+
22
+ Scenario: A custom web get that returns a collection of primitive types
23
+ Given the following categories exist:
24
+ | Name |
25
+ | Cat1 |
26
+ | Cat2 |
27
+ | Cat3 |
28
+ When I call the service method "CategoryNames"
29
+ Then the primitive results should be:
30
+ | Cat1 |
31
+ | Cat2 |
32
+ | Cat3 |
33
+
34
+ Scenario: A custom web get that returns a single primitive type
35
+ Given a category exists
36
+ When I call the service method "FirstCategoryId"
37
+ Then the integer result should be 1
@@ -1,7 +1,7 @@
1
1
  Feature: Service Should Access Basic Resources via SSL using a self-signed certificate
2
2
 
3
3
  Background:
4
- Given an ODataService exists with uri: "https://localhost:44300/SampleService/BasicAuth/Entities.svc" using self-signed certificate and username "admin" and password "passwd"
4
+ Given a HTTPS BasicAuth ODataService exists using self-signed certificate and username "admin" and password "passwd"
5
5
  And blueprints exist for the service
6
6
 
7
7
  Scenario: Service should respond to valid collections
@@ -12,10 +12,10 @@ Scenario: Entity should fill values on protected resource
12
12
  And I save changes
13
13
  And I call "Categories" on the service with args: "1"
14
14
  When I run the query
15
- Then the method "Id" on the result should equal: "1"
16
- And the method "Name" on the result should equal: "Auth Test Category"
15
+ Then the method "Id" on the first result should equal: "1"
16
+ And the method "Name" on the first result should equal: "Auth Test Category"
17
17
 
18
18
  Scenario: Should get SSL failure if SSL used with self-signed certificate and not passing "false" as :verify_ssl option
19
- Given an ODataService exists with uri: "https://localhost:44300/SampleService/Entities.svc" it should throw an exception with message containing "SSL Verification failed"
19
+ Given a HTTPS BasicAuth ODataService exists it should throw an exception with message containing "SSL Verification failed"
20
20
 
21
21
 
@@ -0,0 +1,100 @@
1
+ # this file generated by script/generate pickle
2
+
3
+ # create a model
4
+ Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
5
+ create_model(name, fields)
6
+ end
7
+
8
+ # create n models
9
+ Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
10
+ count.to_i.times { create_model(plural_factory.singularize, fields) }
11
+ end
12
+
13
+ # create models from a table
14
+ Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
15
+ create_models_from_table(plural_factory, table)
16
+ end
17
+
18
+ # find a model
19
+ Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
20
+ find_model!(name, fields)
21
+ end
22
+
23
+ # not find a model
24
+ Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
25
+ find_model(name, fields).should be_nil
26
+ end
27
+
28
+ # find models with a table
29
+ Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
30
+ find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
31
+ end
32
+
33
+ # find exactly n models
34
+ Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
35
+ find_models(plural_factory.singularize, fields).size.should == count.to_i
36
+ end
37
+
38
+ # assert equality of models
39
+ Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
40
+ model!(a).should == model!(b)
41
+ end
42
+
43
+ # assert model is in another model's has_many assoc
44
+ Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
45
+ model_with_associations(owner).send(association).should include(model!(target))
46
+ end
47
+
48
+ # assert model is not in another model's has_many assoc
49
+ Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
50
+ model!(owner).send(association).should_not include(model!(target))
51
+ end
52
+
53
+ # assert model is another model's has_one/belongs_to assoc
54
+ Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
55
+ model!(owner).send(association).should == model!(target)
56
+ end
57
+
58
+ # assert model is not another model's has_one/belongs_to assoc
59
+ Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
60
+ model!(owner).send(association).should_not == model!(target)
61
+ end
62
+
63
+ # assert model.predicate?
64
+ Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
65
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
66
+ model!(name).should send("have_#{predicate.gsub(' ', '_')}")
67
+ else
68
+ model!(name).should send("be_#{predicate.gsub(' ', '_')}")
69
+ end
70
+ end
71
+
72
+ # assert not model.predicate?
73
+ Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
74
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
75
+ model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
76
+ else
77
+ model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
78
+ end
79
+ end
80
+
81
+ # model.attribute.should eql(value)
82
+ # model.attribute.should_not eql(value)
83
+ Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
84
+ actual_value = model(name).send(attribute)
85
+ expectation = expectation.gsub(' ', '_')
86
+
87
+ case expected
88
+ when 'nil', 'true', 'false'
89
+ actual_value.send(expectation, send("be_#{expected}"))
90
+ when /^[+-]?[0-9_]+(\.\d+)?$/
91
+ actual_value.send(expectation, eql(expected.to_f))
92
+ else
93
+ actual_value.to_s.send(expectation, eql(eval(expected)))
94
+ end
95
+ end
96
+
97
+ # assert size of association
98
+ Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
99
+ model!(name).send(association).size.should == size.to_i
100
+ end
@@ -1,29 +1,53 @@
1
- Given /^an ODataService exists with uri: "([^\"]*)"$/ do |uri|
2
- @service = OData::Service.new(uri)
1
+ STANDARD_URL = "http://#{WEBSERVER}:#{HTTP_PORT_NUMBER}/SampleService/RubyOData.svc"
2
+ BASICAUTH_URL = "http://#{WEBSERVER}:#{HTTP_PORT_NUMBER}/SampleService/BasicAuth/RubyOData.svc"
3
+ HTTPS_BASICAUTH_URL = "https://#{WEBSERVER}:#{HTTPS_PORT_NUMBER}/SampleService/BasicAuth/RubyOData.svc"
4
+
5
+ When /^(.*) first (last query )?result('s)?(.*)$/ do |pre, last_query, apos, post|
6
+ step = "#{pre} #{last_query}result#{apos}#{post}"
7
+ first_result
8
+ When step
9
+ end
10
+
11
+ When /^(.*) first (last )?save result(.*)$/ do |pre, last, post|
12
+ step = "#{pre} #{last}save result#{post}"
13
+ first_save
14
+ When step
15
+ end
16
+
17
+ Given /^a HTTP ODataService exists$/ do
18
+ @service = OData::Service.new(STANDARD_URL)
3
19
  end
4
20
 
5
- Given /^a sample HTTP ODataService exists$/ do
6
- @service = OData::Service.new("http://localhost:#{HTTP_PORT_NUMBER}/SampleService/Entities.svc")
21
+ Given /^a HTTP BasicAuth ODataService exists$/ do
22
+ @service = OData::Service.new(BASICAUTH_URL)
7
23
  end
8
24
 
9
- Given /^an ODataService exists with uri: "([^\"]*)" using username "([^\"]*)" and password "([^\"]*)"$/ do |uri, username, password|
10
- @service = OData::Service.new(uri, { :username => username, :password => password })
25
+ Given /^a HTTPS BasicAuth ODataService exists$/ do
26
+ @service = OData::Service.new(HTTPS_BASICAUTH_URL)
11
27
  end
12
28
 
13
- Given /^an ODataService exists with uri: "([^\"]*)" using username "([^\"]*)" and password "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |uri, username, password, msg|
14
- lambda { @service = OData::Service.new(uri, { :username => username, :password => password }) }.should raise_error(msg)
29
+ Given /^a HTTP BasicAuth ODataService exists using username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
30
+ @service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password })
15
31
  end
16
32
 
17
- Given /^an ODataService exists with uri: "([^\"]*)" it should throw an exception with message containing "([^\"]*)"$/ do |uri, msg|
18
- lambda { @service = OData::Service.new(uri) }.should raise_error(/#{msg}.*/)
33
+ Given /^a HTTP BasicAuth ODataService exists using username "([^\"]*)" and password "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |username, password, msg|
34
+ lambda { @service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password }) }.should raise_error(msg)
19
35
  end
20
36
 
21
- Given /^an ODataService exists with uri: "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |uri, msg|
22
- lambda { @service = OData::Service.new(uri) }.should raise_error(msg)
37
+ Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message containing "([^\"]*)"$/ do |msg|
38
+ lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
23
39
  end
24
40
 
25
- Given /^an ODataService exists with uri: "([^\"]*)" using self-signed certificate and username "([^\"]*)" and password "([^\"]*)"$/ do |uri, username, password|
26
- @service = OData::Service.new(uri, { :username => username, :password => password, :verify_ssl => false })
41
+ Given /^a HTTPS BasicAuth ODataService exists it should throw an exception with message containing "([^"]*)"$/ do |msg|
42
+ lambda { @service = OData::Service.new(HTTPS_BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
43
+ end
44
+
45
+ Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message "([^\"]*)"$/ do |msg|
46
+ lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(msg)
47
+ end
48
+
49
+ Given /^a HTTPS BasicAuth ODataService exists using self-signed certificate and username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
50
+ @service = OData::Service.new(HTTPS_BASICAUTH_URL, { :username => username, :password => password, :verify_ssl => false })
27
51
  end
28
52
 
29
53
  When /^I call "([^\"]*)" on the service$/ do |method|
@@ -31,7 +55,11 @@ When /^I call "([^\"]*)" on the service$/ do |method|
31
55
  end
32
56
 
33
57
  Then /^the result should be "([^\"]*)"$/ do |result|
34
- @service_result.should == result
58
+ @service_result.should eq result
59
+ end
60
+
61
+ Then /^the integer result should be ([^\"]*)$/ do |result|
62
+ @service_result.should eq result.to_i
35
63
  end
36
64
 
37
65
  Then /^I should be able to call "([^\"]*)" on the service$/ do |method|
@@ -55,19 +83,19 @@ When /^I run the query$/ do
55
83
  end
56
84
 
57
85
  Then /^the result should be of type "([^\"]*)"$/ do |type|
58
- @service_result.class.to_s.should == type
86
+ @service_result.class.to_s.should eq type
59
87
  end
60
88
 
61
89
  Then /^the result should have a method: "([^\"]*)"$/ do |method|
62
- @service_result.respond_to?(method.to_sym).should == true
90
+ @service_result.respond_to?(method.to_sym).should eq true
63
91
  end
64
92
 
65
93
  Then /^the method "([^\"]*)" on the result should equal: "([^\"]*)"$/ do |method, value|
66
- @service_result.send(method.to_sym).to_s.should == value
94
+ @service_result.send(method.to_sym).to_s.should eq value
67
95
  end
68
96
 
69
97
  Then /^the method "([^\"]*)" on the result should be nil$/ do |method|
70
- @service_result.send(method.to_sym).should == nil
98
+ @service_result.send(method.to_sym).should eq nil
71
99
  end
72
100
 
73
101
  When /^I set "([^\"]*)" on the result to "([^\"]*)"$/ do |property_name, value|
@@ -94,27 +122,17 @@ When /^I ask for the top (\d+)$/ do |top|
94
122
  @service_query.top(top)
95
123
  end
96
124
 
125
+ When /^I ask for the links for "([^\"]*)"$/ do |nav_prop|
126
+ @service_query.links(nav_prop)
127
+ end
128
+
97
129
  Then /^the method "([^\"]*)" on the result should be of type "([^\"]*)"$/ do |method, type|
98
130
  result = @service_result.send(method.to_sym)
99
- result.class.to_s.should == type
131
+ result.class.to_s.should eq type
100
132
  end
101
133
 
102
134
  Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object(?: with (.*))?$/ do |method, object, fields|
103
- fields_hash = {}
104
-
105
- if !fields.nil?
106
- fields.split(', ').each do |field|
107
- if field =~ /^(?:(\w+): "(.*)")$/
108
- key = $1
109
- val = $2
110
- if val =~ /^@@LastSave$/
111
- val = @saved_result
112
- end
113
-
114
- fields_hash.merge!({ key => val })
115
- end
116
- end
117
- end
135
+ fields_hash = parse_fields_string(fields)
118
136
 
119
137
  obj = object.constantize.send(:make, fields_hash)
120
138
  @service.send(method.to_sym, obj)
@@ -125,7 +143,7 @@ When /^I save changes$/ do
125
143
  end
126
144
 
127
145
  Then /^the save result should be of type "([^\"]*)"$/ do |type|
128
- @saved_result.class.to_s.should == type
146
+ @saved_result.class.to_s.should eq type
129
147
  end
130
148
 
131
149
  When /^I call "([^\"]*)" on the service with the last save result$/ do |method|
@@ -137,12 +155,12 @@ When /^I call "([^\"]*)" on the service with the last query result$/ do |method|
137
155
  end
138
156
 
139
157
  Then /^the save result should equal: "([^\"]*)"$/ do |result|
140
- @saved_result.to_s.should == result
158
+ @saved_result.to_s.should eq result
141
159
  end
142
160
 
143
161
  Then /^the method "([^\"]*)" on the save result should equal: "([^\"]*)"$/ do |method, value|
144
162
  result = @saved_result.send(method.to_sym)
145
- result.should == value
163
+ result.should eq value
146
164
  end
147
165
 
148
166
  When /^blueprints exist for the service$/ do
@@ -157,26 +175,14 @@ end
157
175
  Then /^no "([^\"]*)" should exist$/ do |collection|
158
176
  @service.send(collection)
159
177
  results = @service.execute
160
- results.should == []
178
+ results.should eq []
161
179
  end
162
180
 
163
- Given /^the following (.*) exist:$/ do |plural_factory, table|
181
+ Then /^the primitive results should be:$/ do |table|
164
182
  # table is a Cucumber::Ast::Table
165
- factory = plural_factory.singularize
166
- table.hashes.map do |hash|
167
- obj = factory.constantize.send(:make, hash)
168
- @service.send("AddTo#{plural_factory}", obj)
169
- @service.save_changes
170
- end
171
- end
172
-
173
- Given /^(\d+) (.*) exist$/ do |num, plural_factory|
174
- factory = plural_factory.singularize
175
- num.to_i.times do
176
- obj = factory.constantize.send(:make)
177
- @service.send("AddTo#{plural_factory}", obj)
178
- end
179
- @service.save_changes # Batch save
183
+ values = table.hashes
184
+ result_table = Cucumber::Ast::Table.new(values)
185
+ table.diff!(result_table)
180
186
  end
181
187
 
182
188
  Then /^the result should be:$/ do |table|
@@ -197,7 +203,7 @@ Then /^the result should be:$/ do |table|
197
203
 
198
204
  result_table = Cucumber::Ast::Table.new(results)
199
205
 
200
- table.diff!(result_table)
206
+ table.diff!(result_table)
201
207
  end
202
208
 
203
209
  Then /^the save result should be:$/ do |table|
@@ -222,7 +228,7 @@ Then /^the save result should be:$/ do |table|
222
228
  end
223
229
 
224
230
  Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
225
- (Object.const_defined? klass_name).should == true
231
+ (Object.const_defined? klass_name).should eq true
226
232
  end
227
233
 
228
234
  # Operations against a method on the service result
@@ -232,13 +238,12 @@ When /^I call "([^\"]*)" for "([^\"]*)" on the result$/ do |method2, method1|
232
238
  end
233
239
 
234
240
  Then /^the operation should not be null$/ do
235
- @operation_result.nil?.should == false
241
+ @operation_result.nil?.should eq false
236
242
  end
237
243
 
238
-
239
244
  Then /^the method "([^\"]*)" on the result's method "([^\"]*)" should equal: "([^\"]*)"$/ do |method, result_method, value|
240
245
  obj = @service_result.send(result_method.to_sym)
241
- obj.send(method.to_sym).to_s.should == value
246
+ obj.send(method.to_sym).to_s.should eq value
242
247
  end
243
248
 
244
249
  When /^I set "([^\"]*)" on the result's method "([^\"]*)" to "([^\"]*)"$/ do |property_name, result_method, value|
@@ -249,20 +254,49 @@ end
249
254
  Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
250
255
  methods = method_name.split '.'
251
256
  if methods.length == 1
252
- @service_result.send(method_name).class.to_s.should == type
257
+ @service_result.send(method_name).class.to_s.should eq type
253
258
  else
254
- @service_result.send(methods[0]).send(methods[1]).class.to_s.should == type
259
+ @service_result.send(methods[0]).send(methods[1]).class.to_s.should eq type
260
+ end
261
+ end
262
+ Then /^the "([^\"]*)" method on the object should return a (.*)/ do |method_name, type|
263
+ methods = method_name.split '.'
264
+ if methods.length == 1
265
+ @service_result.first.send(method_name).class.to_s.should eq type
266
+ else
267
+ @service_result.first.send(methods[0]).send(methods[1]).class.to_s.should eq type
255
268
  end
256
-
257
269
  end
270
+
258
271
  Then /^I store the last query result for comparison$/ do
259
272
  @stored_query_result = @service_result
260
273
  end
274
+
261
275
  Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
262
276
  methods = method_name.split '.'
263
277
  if methods.length == 1
264
- @service_result.send(method_name).xmlschema(3).should == @stored_query_result.send(method_name).xmlschema(3)
278
+ @service_result.send(method_name).xmlschema(3).should eq @stored_query_result.send(method_name).xmlschema(3)
279
+ else
280
+ @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should eq @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
281
+ end
282
+ end
283
+
284
+ Then /^show me the results$/ do
285
+ puts @service_result
286
+ end
287
+
288
+ Then /^the result count should be (\d+)$/ do |expected_count|
289
+ @service_result.count.should eq expected_count.to_i
290
+ end
291
+
292
+ When /^I add a link between #{capture_model} and #{capture_model} on "([^"]*)"$/ do |parent, child, property|
293
+ @service.add_link(created_model(parent), property, created_model(child))
294
+ end
295
+
296
+ Given /^I call the service method "([^"]*)"(?: with (.*))?$/ do |method, args|
297
+ if args
298
+ @service_result = @service.send(method, args)
265
299
  else
266
- @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should == @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
300
+ @service_result = @service.send(method)
267
301
  end
268
302
  end