Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed the rest of the files to use LFs for line ending and soft tabs

  • Loading branch information...
commit 48b5367e91d882b2dfe649705843b13b17cd1e70 1 parent 1cc4d95
@visoft authored
View
74 CHANGELOG.rdoc
@@ -1,38 +1,38 @@
-= ruby_odata Change Log
-
-=== 0.0.1
-* New Features
- * Basic CRUD Operations
- * Query Enhancement: Filters
- * Query Enhancement: Expands
-
-=== 0.0.2
-* New Features
- * Query Enhancement: Order By (both desc and asc)
-
-=== 0.0.3
-* Bug Fixes
- * Rearranged code to match the gem name. Things were mismatched between odata_ruby and ruby_odata.
-
-=== 0.0.4
-* New Features
- * Query Enhancement: skip
- * Query Enhancement: top
- * Ability to perform paging using skip and top together
- * Updated README with examples for order_by, skip, and top
-
-=== 0.0.5
-* Bug Fixes
- * Works with Ruby 1.9.1
- * Works with ActiveSupport 3.0.0.beta4
-
-=== 0.0.6
-* New Features
- * Ability to batch saves (Adds, Updates, Deletes); this will help save on network chatter
-
-=== 0.0.7
-* New Features
- * Complex Types are now supported
- * Support for Edm.Int16, Edm.Int32, Edm.Int64
- * Support for Edm.Decimal
+= ruby_odata Change Log
+
+=== 0.0.1
+* New Features
+ * Basic CRUD Operations
+ * Query Enhancement: Filters
+ * Query Enhancement: Expands
+
+=== 0.0.2
+* New Features
+ * Query Enhancement: Order By (both desc and asc)
+
+=== 0.0.3
+* Bug Fixes
+ * Rearranged code to match the gem name. Things were mismatched between odata_ruby and ruby_odata.
+
+=== 0.0.4
+* New Features
+ * Query Enhancement: skip
+ * Query Enhancement: top
+ * Ability to perform paging using skip and top together
+ * Updated README with examples for order_by, skip, and top
+
+=== 0.0.5
+* Bug Fixes
+ * Works with Ruby 1.9.1
+ * Works with ActiveSupport 3.0.0.beta4
+
+=== 0.0.6
+* New Features
+ * Ability to batch saves (Adds, Updates, Deletes); this will help save on network chatter
+
+=== 0.0.7
+* New Features
+ * Complex Types are now supported
+ * Support for Edm.Int16, Edm.Int32, Edm.Int64
+ * Support for Edm.Decimal
* Support for Edm.DateTime
View
48 LICENSE
@@ -1,24 +1,24 @@
-Copyright (c) 2010, Visoft, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of Visoft, Inc. nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL VISOFT, INC. BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Copyright (c) 2010, Visoft, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Visoft, Inc. nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL VISOFT, INC. BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
56 Rakefile
@@ -1,28 +1,28 @@
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rd|
- rd.main = "README.rdoc"
- rd.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb")
- rd.rdoc_dir = 'doc'
-end
-
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "ruby_odata"
- gemspec.summary = "Ruby consumer of OData services."
- gemspec.description = "An OData Client Library for Ruby. Use this to interact with OData services"
- gemspec.email = "damien.white@visoftinc.com"
- gemspec.homepage = "http://github.com/visoft/ruby_odata"
- gemspec.authors = ["Damien White"]
- gemspec.add_dependency('activesupport', '>= 2.3.5')
- gemspec.add_dependency('rest-client', '>= 1.5.1')
- gemspec.add_dependency('nokogiri', '>= 1.4.2')
- gemspec.rubyforge_project = 'ruby-odata'
- end
- Jeweler::GemcutterTasks.new
- Jeweler::RubyforgeTasks.new do |rubyforge|
- rubyforge.doc_task = "rdoc"
- end
-rescue LoadError
- puts "Jeweler not available. Install it with: gem install jeweler"
-end
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rd|
+ rd.main = "README.rdoc"
+ rd.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb")
+ rd.rdoc_dir = 'doc'
+end
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "ruby_odata"
+ gemspec.summary = "Ruby consumer of OData services."
+ gemspec.description = "An OData Client Library for Ruby. Use this to interact with OData services"
+ gemspec.email = "damien.white@visoftinc.com"
+ gemspec.homepage = "http://github.com/visoft/ruby_odata"
+ gemspec.authors = ["Damien White"]
+ gemspec.add_dependency('activesupport', '>= 2.3.5')
+ gemspec.add_dependency('rest-client', '>= 1.5.1')
+ gemspec.add_dependency('nokogiri', '>= 1.4.2')
+ gemspec.rubyforge_project = 'ruby-odata'
+ end
+ Jeweler::GemcutterTasks.new
+ Jeweler::RubyforgeTasks.new do |rubyforge|
+ rubyforge.doc_task = "rdoc"
+ end
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
View
2  VERSION
@@ -1 +1 @@
-0.0.7
+0.0.7
View
188 features/batch_request.feature
@@ -1,94 +1,94 @@
-Feature: Batch request
- In order to minimize network traffic
- As a user of the library
- I want to be able to batch changes (Add/Update/Delete) and persist the batch instead of one at a time
-
-Background:
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
- And blueprints exist for the service
-
-Scenario: Save Changes should allow for batch additions
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
- When I save changes
- Then the save result should equal: "true"
- When I call "Products" on the service
- And I order by: "Name"
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 |
- | Product 2 |
-
-Scenario: Save Changes should allow for batch updates
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
- When I save changes
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Product 1'"
- And I run the query
- And I set "Name" on the result to "Product 1 - Updated"
- And I call "update_object" on the service with the last query result
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Product 2'"
- And I run the query
- And I set "Name" on the result to "Product 2 - Updated"
- And I call "update_object" on the service with the last query result
- When I save changes
- When I call "Products" on the service
- And I order by: "Name"
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 - Updated |
- | Product 2 - Updated |
-
-Scenario: Save Changes should allow for batch deletes
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
- When I save changes
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Product 2'"
- And I run the query
- And I call "delete_object" on the service with the last query result
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Product 3'"
- And I run the query
- And I call "delete_object" on the service with the last query result
- When I save changes
- When I call "Products" on the service
- And I order by: "Name"
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 |
- | Product 4 |
-
-Scenario: Save Changes should allow for a mix of adds, updates, and deletes to be batched
- Given the following Products exist:
- | Name |
- | Product 1 |
- | Product 2 |
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Product 1'"
- And I run the query
- And I set "Name" on the result to "Product 1 - Updated"
- And I call "update_object" on the service with the last query result
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Product 2'"
- And I run the query
- And I call "delete_object" on the service with the last query result
- When I save changes
- When I call "Products" on the service
- And I order by: "Name"
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 - Updated |
- | Product 3 |
- | Product 4 |
-
+Feature: Batch request
+ In order to minimize network traffic
+ As a user of the library
+ I want to be able to batch changes (Add/Update/Delete) and persist the batch instead of one at a time
+
+Background:
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
+ And blueprints exist for the service
+
+Scenario: Save Changes should allow for batch additions
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
+ When I save changes
+ Then the save result should equal: "true"
+ When I call "Products" on the service
+ And I order by: "Name"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+
+Scenario: Save Changes should allow for batch updates
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
+ When I save changes
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Product 1'"
+ And I run the query
+ And I set "Name" on the result to "Product 1 - Updated"
+ And I call "update_object" on the service with the last query result
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Product 2'"
+ And I run the query
+ And I set "Name" on the result to "Product 2 - Updated"
+ And I call "update_object" on the service with the last query result
+ When I save changes
+ When I call "Products" on the service
+ And I order by: "Name"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 - Updated |
+ | Product 2 - Updated |
+
+Scenario: Save Changes should allow for batch deletes
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
+ When I save changes
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Product 2'"
+ And I run the query
+ And I call "delete_object" on the service with the last query result
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Product 3'"
+ And I run the query
+ And I call "delete_object" on the service with the last query result
+ When I save changes
+ When I call "Products" on the service
+ And I order by: "Name"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 |
+ | Product 4 |
+
+Scenario: Save Changes should allow for a mix of adds, updates, and deletes to be batched
+ Given the following Products exist:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Product 1'"
+ And I run the query
+ And I set "Name" on the result to "Product 1 - Updated"
+ And I call "update_object" on the service with the last query result
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Product 2'"
+ And I run the query
+ And I call "delete_object" on the service with the last query result
+ When I save changes
+ When I call "Products" on the service
+ And I order by: "Name"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 - Updated |
+ | Product 3 |
+ | Product 4 |
+
View
104 features/complex_types.feature
@@ -1,52 +1,52 @@
-Feature: Complex types
- In order to fully support OData services
- As a user of ruby_odata
- I want to be able to manage objects with complex types
-
-Background:
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
- And blueprints exist for the service
-
-Scenario: The proxy must generate classes for complex types if they exist
- Then a class named "AuditFields" should exist
-
-Scenario: Complex properties on an entity must be the correct type
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- And I call "Products" on the service with args: "1"
- When I run the query
- Then the result should have a method: "AuditFields"
- And the method "AuditFields" on the result should be of type "AuditFields"
-
-Scenario: Complex properties on an entity must be filled
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- And I call "Products" on the service with args: "1"
- When I run the query
- Then the result should have a method: "AuditFields"
- When I call "CreateDate" for "AuditFields" on the result
- Then the operation should not be null
-
-# TODO: This scenario should have the AuditFields.CreatedBy field set in the Given
-# instead it is set by the blueprint
-Scenario: Complex properties should be able to be added
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- And I call "Products" on the service with args: "1"
- When I run the query
- Then the method "CreatedBy" on the result's method "AuditFields" should equal: "Cucumber"
-
-Scenario: Complex propertis should be able to be updated
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- And I call "Products" on the service with args: "1"
- When I run the query
- When I set "CreatedBy" on the result's method "AuditFields" to "This Test"
- And I call "update_object" on the service with the last query result
- And I save changes
- Then the save result should equal: "true"
- When I call "Products" on the service with args: "1"
- And I run the query
- Then the method "CreatedBy" on the result's method "AuditFields" should equal: "This Test"
-
-
+Feature: Complex types
+ In order to fully support OData services
+ As a user of ruby_odata
+ I want to be able to manage objects with complex types
+
+Background:
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
+ And blueprints exist for the service
+
+Scenario: The proxy must generate classes for complex types if they exist
+ Then a class named "AuditFields" should exist
+
+Scenario: Complex properties on an entity must be the correct type
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ And I call "Products" on the service with args: "1"
+ When I run the query
+ Then the result should have a method: "AuditFields"
+ And the method "AuditFields" on the result should be of type "AuditFields"
+
+Scenario: Complex properties on an entity must be filled
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ And I call "Products" on the service with args: "1"
+ When I run the query
+ Then the result should have a method: "AuditFields"
+ When I call "CreateDate" for "AuditFields" on the result
+ Then the operation should not be null
+
+# TODO: This scenario should have the AuditFields.CreatedBy field set in the Given
+# instead it is set by the blueprint
+Scenario: Complex properties should be able to be added
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ And I call "Products" on the service with args: "1"
+ When I run the query
+ Then the method "CreatedBy" on the result's method "AuditFields" should equal: "Cucumber"
+
+Scenario: Complex propertis should be able to be updated
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ And I call "Products" on the service with args: "1"
+ When I run the query
+ When I set "CreatedBy" on the result's method "AuditFields" to "This Test"
+ And I call "update_object" on the service with the last query result
+ And I save changes
+ Then the save result should equal: "true"
+ When I call "Products" on the service with args: "1"
+ And I run the query
+ Then the method "CreatedBy" on the result's method "AuditFields" should equal: "This Test"
+
+
View
306 features/query_builder.feature
@@ -1,153 +1,153 @@
-Feature: Query Builder
- In order to query OData services
- As a user
- I want to be able to perform valid OData protocol operations
-
-Background:
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
- And blueprints exist for the service
-
-# Expand
-Scenario: Navigation Properties should be able to be eager loaded
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
- And I save changes
- And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave"
- And I save changes
- And I call "Products" on the service with args: "1"
- And I expand the query to include "Category"
- When I run the query
- Then the method "Category" on the result should be of type "Category"
- And the method "Name" on the result's method "Category" should equal: "Test Category"
- And the method "Id" on the result's method "Category" should equal: "1"
-
-
-# Filters
-Scenario: Filters should be allowed on the root level entity
-# Filter
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
- When I save changes
- When I call "Products" on the service
- And I filter the query with: "Name eq 'Test Product'"
- And I run the query
- Then the method "Name" on the result should equal: "Test Product"
-
-
-# Order By
-Scenario: Order by should be allowed on the root level entity
- Given the following Products exist:
- | Name |
- | Product 2 |
- | Product 4 |
- | Product 5 |
- | Product 1 |
- | Product 3 |
- When I call "Products" on the service
- And I order by: "Name"
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 |
- | Product 2 |
- | Product 3 |
- | Product 4 |
- | Product 5 |
-
-Scenario: Order by should accept sorting descending
- Given the following Products exist:
- | Name |
- | Product 2 |
- | Product 4 |
- | Product 5 |
- | Product 1 |
- | Product 3 |
- When I call "Products" on the service
- And I order by: "Name desc"
- And I run the query
- Then the result should be:
- | Name |
- | Product 5 |
- | Product 4 |
- | Product 3 |
- | Product 2 |
- | Product 1 |
-
-Scenario: Order by should access sorting acsending
- Given the following Products exist:
- | Name |
- | Product 2 |
- | Product 4 |
- | Product 5 |
- | Product 1 |
- | Product 3 |
- When I call "Products" on the service
- And I order by: "Name asc"
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 |
- | Product 2 |
- | Product 3 |
- | Product 4 |
- | Product 5 |
-
-
-# Skip
-Scenario: Skip should be allowed on the root level entity
- Given the following Products exist:
- | Name |
- | Product 1 |
- | Product 2 |
- | Product 3 |
- | Product 4 |
- | Product 5 |
- When I call "Products" on the service
- And I skip 3
- And I run the query
- Then the result should be:
- | Name |
- | Product 4 |
- | Product 5 |
-
-
-# Top
-Scenario: Top should be allowed on the root level entity
- Given the following Products exist:
- | Name |
- | Product 1 |
- | Product 2 |
- | Product 3 |
- | Product 4 |
- | Product 5 |
- When I call "Products" on the service
- And I ask for the top 3
- And I run the query
- Then the result should be:
- | Name |
- | Product 1 |
- | Product 2 |
- | Product 3 |
-
-Scenario: Top should be able to be used along with skip for paging
- Given the following Products exist:
- | Name |
- | Product 1 |
- | Product 2 |
- | Product 3 |
- | Product 4 |
- | Product 5 |
- | Product 6 |
- When I call "Products" on the service
- And I skip 2
- And I ask for the top 2
- And I run the query
- Then the result should be:
- | Name |
- | Product 3 |
- | Product 4 |
-
-
-
-
-
-
-
+Feature: Query Builder
+ In order to query OData services
+ As a user
+ I want to be able to perform valid OData protocol operations
+
+Background:
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
+ And blueprints exist for the service
+
+# Expand
+Scenario: Navigation Properties should be able to be eager loaded
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
+ And I save changes
+ And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave"
+ And I save changes
+ And I call "Products" on the service with args: "1"
+ And I expand the query to include "Category"
+ When I run the query
+ Then the method "Category" on the result should be of type "Category"
+ And the method "Name" on the result's method "Category" should equal: "Test Category"
+ And the method "Id" on the result's method "Category" should equal: "1"
+
+
+# Filters
+Scenario: Filters should be allowed on the root level entity
+# Filter
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
+ When I save changes
+ When I call "Products" on the service
+ And I filter the query with: "Name eq 'Test Product'"
+ And I run the query
+ Then the method "Name" on the result should equal: "Test Product"
+
+
+# Order By
+Scenario: Order by should be allowed on the root level entity
+ Given the following Products exist:
+ | Name |
+ | Product 2 |
+ | Product 4 |
+ | Product 5 |
+ | Product 1 |
+ | Product 3 |
+ When I call "Products" on the service
+ And I order by: "Name"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ | Product 3 |
+ | Product 4 |
+ | Product 5 |
+
+Scenario: Order by should accept sorting descending
+ Given the following Products exist:
+ | Name |
+ | Product 2 |
+ | Product 4 |
+ | Product 5 |
+ | Product 1 |
+ | Product 3 |
+ When I call "Products" on the service
+ And I order by: "Name desc"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 5 |
+ | Product 4 |
+ | Product 3 |
+ | Product 2 |
+ | Product 1 |
+
+Scenario: Order by should access sorting acsending
+ Given the following Products exist:
+ | Name |
+ | Product 2 |
+ | Product 4 |
+ | Product 5 |
+ | Product 1 |
+ | Product 3 |
+ When I call "Products" on the service
+ And I order by: "Name asc"
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ | Product 3 |
+ | Product 4 |
+ | Product 5 |
+
+
+# Skip
+Scenario: Skip should be allowed on the root level entity
+ Given the following Products exist:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ | Product 3 |
+ | Product 4 |
+ | Product 5 |
+ When I call "Products" on the service
+ And I skip 3
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 4 |
+ | Product 5 |
+
+
+# Top
+Scenario: Top should be allowed on the root level entity
+ Given the following Products exist:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ | Product 3 |
+ | Product 4 |
+ | Product 5 |
+ When I call "Products" on the service
+ And I ask for the top 3
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ | Product 3 |
+
+Scenario: Top should be able to be used along with skip for paging
+ Given the following Products exist:
+ | Name |
+ | Product 1 |
+ | Product 2 |
+ | Product 3 |
+ | Product 4 |
+ | Product 5 |
+ | Product 6 |
+ When I call "Products" on the service
+ And I skip 2
+ And I ask for the top 2
+ And I run the query
+ Then the result should be:
+ | Name |
+ | Product 3 |
+ | Product 4 |
+
+
+
+
+
+
+
View
98 features/service.feature
@@ -1,49 +1,49 @@
-Feature: Service Should Generate a Proxy
- In order to consume the OData
- As a user
- I want to be able to access data
-
-Background:
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
- And blueprints exist for the service
-
-Scenario: Service should respond to valid collections
- Then I should be able to call "Categories" on the service
-
-Scenario: Service should not respond to an invalid collection
- Then I should not be able to call "X" on the service
-
-Scenario: Service should respond to accessing a single entity by ID
- Then I should be able to call "Categories" on the service with args: "1"
-
-Scenario: Access an entity by ID should return the entity type
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
- And I save changes
- And I call "Categories" on the service with args: "1"
- When I run the query
- Then the result should be of type "Category"
-
-Scenario: Entity should have the correct accessors
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
- And I save changes
- And I call "Categories" on the service with args: "1"
- When I run the query
- Then the result should have a method: "Id"
- And the result should have a method: "Name"
-
-Scenario: Entity should fill values
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
- And I save changes
- And I call "Categories" on the service with args: "1"
- When I run the query
- Then the method "Id" on the result should equal: "1"
- And the method "Name" on the result should equal: "Test Category"
-
-Scenario: Navigation Properties should be included in results
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- And I call "Products" on the service with args: "1"
- When I run the query
- Then the result should have a method: "Category"
- And the method "Category" on the result should be nil
-
+Feature: Service Should Generate a Proxy
+ In order to consume the OData
+ As a user
+ I want to be able to access data
+
+Background:
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
+ And blueprints exist for the service
+
+Scenario: Service should respond to valid collections
+ Then I should be able to call "Categories" on the service
+
+Scenario: Service should not respond to an invalid collection
+ Then I should not be able to call "X" on the service
+
+Scenario: Service should respond to accessing a single entity by ID
+ Then I should be able to call "Categories" on the service with args: "1"
+
+Scenario: Access an entity by ID should return the entity type
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
+ And I save changes
+ And I call "Categories" on the service with args: "1"
+ When I run the query
+ Then the result should be of type "Category"
+
+Scenario: Entity should have the correct accessors
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
+ And I save changes
+ And I call "Categories" on the service with args: "1"
+ When I run the query
+ Then the result should have a method: "Id"
+ And the result should have a method: "Name"
+
+Scenario: Entity should fill values
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
+ And I save changes
+ And I call "Categories" on the service with args: "1"
+ When I run the query
+ Then the method "Id" on the result should equal: "1"
+ And the method "Name" on the result should equal: "Test Category"
+
+Scenario: Navigation Properties should be included in results
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ And I call "Products" on the service with args: "1"
+ When I run the query
+ Then the result should have a method: "Category"
+ And the method "Category" on the result should be nil
+
View
88 features/service_manage.feature
@@ -1,44 +1,44 @@
-Feature: Service management
- In order to manage entities
- As a admin
- I want to be able to add, edit, and delete entities
-
-Background:
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
- And blueprints exist for the service
-
-Scenario: Service should respond to AddToEntityName for adding objects
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Sample Product"
- When I save changes
- Then the save result should be of type "Product"
- And the method "Name" on the save result should equal: "Sample Product"
-
-Scenario: Service should allow for deletes
- Given I call "AddToProducts" on the service with a new "Product" object
- When I save changes
- Then the save result should be of type "Product"
- When I call "delete_object" on the service with the last save result
- And I save changes
- Then the save result should equal: "true"
- And no "Products" should exist
-
-Scenario: Untracked entities shouldn't be able to be deleted
- Given I call "delete_object" on the service with a new "Product" object it should throw an exception with message "You cannot delete a non-tracked entity"
-
-Scenario: Entities should be able to be updated
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
- When I save changes
- And I call "Products" on the service with args: "1"
- And I run the query
- Then the method "Name" on the result should equal: "Test Product"
- When I set "Name" on the result to "Changed Test Product"
- Then the method "Name" on the result should equal: "Changed Test Product"
- And I call "update_object" on the service with the last query result
- And I save changes
- Then the save result should equal: "true"
- When I call "Products" on the service with args: "1"
- And I run the query
- Then the method "Name" on the result should equal: "Changed Test Product"
-
-Scenario: Untracked entities shouldn't be able to be updated
- 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"
+Feature: Service management
+ In order to manage entities
+ As a admin
+ I want to be able to add, edit, and delete entities
+
+Background:
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
+ And blueprints exist for the service
+
+Scenario: Service should respond to AddToEntityName for adding objects
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Sample Product"
+ When I save changes
+ Then the save result should be of type "Product"
+ And the method "Name" on the save result should equal: "Sample Product"
+
+Scenario: Service should allow for deletes
+ Given I call "AddToProducts" on the service with a new "Product" object
+ When I save changes
+ Then the save result should be of type "Product"
+ When I call "delete_object" on the service with the last save result
+ And I save changes
+ Then the save result should equal: "true"
+ And no "Products" should exist
+
+Scenario: Untracked entities shouldn't be able to be deleted
+ Given I call "delete_object" on the service with a new "Product" object it should throw an exception with message "You cannot delete a non-tracked entity"
+
+Scenario: Entities should be able to be updated
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
+ When I save changes
+ And I call "Products" on the service with args: "1"
+ And I run the query
+ Then the method "Name" on the result should equal: "Test Product"
+ When I set "Name" on the result to "Changed Test Product"
+ Then the method "Name" on the result should equal: "Changed Test Product"
+ And I call "update_object" on the service with the last query result
+ And I save changes
+ Then the save result should equal: "true"
+ When I call "Products" on the service with args: "1"
+ And I run the query
+ Then the method "Name" on the result should equal: "Changed Test Product"
+
+Scenario: Untracked entities shouldn't be able to be updated
+ 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"
View
486 features/step_definitions/service_steps.rb
@@ -1,244 +1,244 @@
-Given /^an ODataService exists with uri: "([^\"]*)"$/ do |uri|
- @service = OData::Service.new(uri)
-end
-
-When /^I call "([^\"]*)" on the service$/ do |method|
- @service_query = @service.send(method)
-end
-
-Then /^the result should be "([^\"]*)"$/ do |result|
- @service_result.should == result
-end
-
-Then /^I should be able to call "([^\"]*)" on the service$/ do |method|
- lambda { @service.send(method) }.should_not raise_error
-end
-
-Then /^I should not be able to call "([^\"]*)" on the service$/ do |method|
- lambda { @service.send(method) }.should raise_error
-end
-
-Then /^I should be able to call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
- lambda { @service.send(method, args) }.should_not raise_error
-end
-
-When /^I call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
- @service_query = @service.send(method, args)
-end
-
-When /^I run the query$/ do
- @service_result = @service.execute
-end
-
-Then /^the result should be of type "([^\"]*)"$/ do |type|
- @service_result.class.to_s.should == type
-end
-
-Then /^the result should have a method: "([^\"]*)"$/ do |method|
- @service_result.respond_to?(method.to_sym).should == true
-end
-
-Then /^the method "([^\"]*)" on the result should equal: "([^\"]*)"$/ do |method, value|
- @service_result.send(method.to_sym).to_s.should == value
-end
-
-Then /^the method "([^\"]*)" on the result should be nil$/ do |method|
- @service_result.send(method.to_sym).should == nil
-end
-
-When /^I set "([^\"]*)" on the result to "([^\"]*)"$/ do |property_name, value|
- @service_result.send("#{property_name}=", value)
-end
-
-Given /^I expand the query to include "([^\"]*)"$/ do |expands|
- @service_query.expand(expands)
-end
-
-When /^I filter the query with: "([^\"]*)"$/ do |filter|
- @service_query.filter(filter)
-end
-
-When /^I order by: "([^\"]*)"$/ do |order|
- @service_query.order_by(order)
-end
-
-When /^I skip (\d+)$/ do |skip|
- @service_query.skip(skip)
-end
-
-When /^I ask for the top (\d+)$/ do |top|
- @service_query.top(top)
-end
-
-Then /^the method "([^\"]*)" on the result should be of type "([^\"]*)"$/ do |method, type|
- result = @service_result.send(method.to_sym)
- result.class.to_s.should == type
-end
-
-Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object(?: with (.*))?$/ do |method, object, fields|
- fields_hash = {}
-
- if !fields.nil?
- fields.split(', ').each do |field|
- if field =~ /^(?:(\w+): "(.*)")$/
- key = $1
- val = $2
- if val =~ /^@@LastSave$/
- val = @saved_result
- end
-
- fields_hash.merge!({ key => val })
- end
- end
- end
-
- obj = object.constantize.send(:make, fields_hash)
- @service.send(method.to_sym, obj)
-end
-
-When /^I save changes$/ do
- @saved_result = @service.save_changes
-end
-
-Then /^the save result should be of type "([^\"]*)"$/ do |type|
- @saved_result.class.to_s.should == type
-end
-
-When /^I call "([^\"]*)" on the service with the last save result$/ do |method|
- @service.send(method.to_sym, @saved_result)
-end
-
-When /^I call "([^\"]*)" on the service with the last query result$/ do |method|
- @service.send(method.to_sym, @service_result)
-end
-
-Then /^the save result should equal: "([^\"]*)"$/ do |result|
- @saved_result.to_s.should == result
-end
-
-Then /^the method "([^\"]*)" on the save result should equal: "([^\"]*)"$/ do |method, value|
- result = @saved_result.send(method.to_sym)
- result.should == value
-end
-
-When /^blueprints exist for the service$/ do
- require File.expand_path(File.dirname(__FILE__) + "../../../test/blueprints")
-end
-
-Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object it should throw an exception with message "([^\"]*)"$/ do |method, object, msg|
- obj = object.constantize.send :make
- lambda { @service.send(method.to_sym, obj) }.should raise_error(msg)
-end
-
-Then /^no "([^\"]*)" should exist$/ do |collection|
- @service.send(collection)
- results = @service.execute
- results.should == []
-end
-
-Given /^the following (.*) exist:$/ do |plural_factory, table|
- # table is a Cucumber::Ast::Table
- factory = plural_factory.singularize
- table.hashes.map do |hash|
- obj = factory.constantize.send(:make, hash)
- @service.send("AddTo#{plural_factory}", obj)
- @service.save_changes
- end
-end
-
-Given /^(\d+) (.*) exist$/ do |num, plural_factory|
- factory = plural_factory.singularize
- num.to_i.times do
- obj = factory.constantize.send(:make)
- @service.send("AddTo#{plural_factory}", obj)
- end
- @service.save_changes # Batch save
-end
-
-Then /^the result should be:$/ do |table|
- # table is a Cucumber::Ast::Table
-
- fields = table.hashes[0].keys
-
- # Build an array of hashes so that we can compare tables
- results = []
-
- @service_result.each do |result|
- obj_hash = Hash.new
- fields.each do |field|
- obj_hash[field] = result.send(field)
- end
- results << obj_hash
- end
-
- result_table = Cucumber::Ast::Table.new(results)
-
- table.diff!(result_table)
-end
-
-Then /^the save result should be:$/ do |table|
- # table is a Cucumber::Ast::Table
-
- fields = table.hashes[0].keys
-
- # Build an array of hashes so that we can compare tables
- results = []
-
- @saved_result.each do |result|
- obj_hash = Hash.new
- fields.each do |field|
- obj_hash[field] = result.send(field)
- end
- results << obj_hash
- end
-
- result_table = Cucumber::Ast::Table.new(results)
-
- table.diff!(result_table)
-end
-
-Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
- (Object.const_defined? klass_name).should == true
-end
-
-# Operations against a method on the service result
-When /^I call "([^\"]*)" for "([^\"]*)" on the result$/ do |method2, method1|
- r1 = @service_result.send(method1)
- @operation_result = r1.send(method2)
-end
-
-Then /^the operation should not be null$/ do
- @operation_result.nil?.should == false
-end
-
-
-Then /^the method "([^\"]*)" on the result's method "([^\"]*)" should equal: "([^\"]*)"$/ do |method, result_method, value|
- obj = @service_result.send(result_method.to_sym)
- obj.send(method.to_sym).to_s.should == value
-end
-
-When /^I set "([^\"]*)" on the result's method "([^\"]*)" to "([^\"]*)"$/ do |property_name, result_method, value|
- @service_result.send(result_method).send("#{property_name}=", value)
-end
-
-# Type tests
-Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
- methods = method_name.split '.'
- if methods.length == 1
- @service_result.send(method_name).class.to_s.should == type
- else
- @service_result.send(methods[0]).send(methods[1]).class.to_s.should == type
- end
-
-end
-Then /^I store the last query result for comparison$/ do
- @stored_query_result = @service_result
-end
-Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
- methods = method_name.split '.'
- if methods.length == 1
- @service_result.send(method_name).xmlschema(3).should == @stored_query_result.send(method_name).xmlschema(3)
- else
- @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should == @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
- end
+Given /^an ODataService exists with uri: "([^\"]*)"$/ do |uri|
+ @service = OData::Service.new(uri)
+end
+
+When /^I call "([^\"]*)" on the service$/ do |method|
+ @service_query = @service.send(method)
+end
+
+Then /^the result should be "([^\"]*)"$/ do |result|
+ @service_result.should == result
+end
+
+Then /^I should be able to call "([^\"]*)" on the service$/ do |method|
+ lambda { @service.send(method) }.should_not raise_error
+end
+
+Then /^I should not be able to call "([^\"]*)" on the service$/ do |method|
+ lambda { @service.send(method) }.should raise_error
+end
+
+Then /^I should be able to call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
+ lambda { @service.send(method, args) }.should_not raise_error
+end
+
+When /^I call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
+ @service_query = @service.send(method, args)
+end
+
+When /^I run the query$/ do
+ @service_result = @service.execute
+end
+
+Then /^the result should be of type "([^\"]*)"$/ do |type|
+ @service_result.class.to_s.should == type
+end
+
+Then /^the result should have a method: "([^\"]*)"$/ do |method|
+ @service_result.respond_to?(method.to_sym).should == true
+end
+
+Then /^the method "([^\"]*)" on the result should equal: "([^\"]*)"$/ do |method, value|
+ @service_result.send(method.to_sym).to_s.should == value
+end
+
+Then /^the method "([^\"]*)" on the result should be nil$/ do |method|
+ @service_result.send(method.to_sym).should == nil
+end
+
+When /^I set "([^\"]*)" on the result to "([^\"]*)"$/ do |property_name, value|
+ @service_result.send("#{property_name}=", value)
+end
+
+Given /^I expand the query to include "([^\"]*)"$/ do |expands|
+ @service_query.expand(expands)
+end
+
+When /^I filter the query with: "([^\"]*)"$/ do |filter|
+ @service_query.filter(filter)
+end
+
+When /^I order by: "([^\"]*)"$/ do |order|
+ @service_query.order_by(order)
+end
+
+When /^I skip (\d+)$/ do |skip|
+ @service_query.skip(skip)
+end
+
+When /^I ask for the top (\d+)$/ do |top|
+ @service_query.top(top)
+end
+
+Then /^the method "([^\"]*)" on the result should be of type "([^\"]*)"$/ do |method, type|
+ result = @service_result.send(method.to_sym)
+ result.class.to_s.should == type
+end
+
+Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object(?: with (.*))?$/ do |method, object, fields|
+ fields_hash = {}
+
+ if !fields.nil?
+ fields.split(', ').each do |field|
+ if field =~ /^(?:(\w+): "(.*)")$/
+ key = $1
+ val = $2
+ if val =~ /^@@LastSave$/
+ val = @saved_result
+ end
+
+ fields_hash.merge!({ key => val })
+ end
+ end
+ end
+
+ obj = object.constantize.send(:make, fields_hash)
+ @service.send(method.to_sym, obj)
+end
+
+When /^I save changes$/ do
+ @saved_result = @service.save_changes
+end
+
+Then /^the save result should be of type "([^\"]*)"$/ do |type|
+ @saved_result.class.to_s.should == type
+end
+
+When /^I call "([^\"]*)" on the service with the last save result$/ do |method|
+ @service.send(method.to_sym, @saved_result)
+end
+
+When /^I call "([^\"]*)" on the service with the last query result$/ do |method|
+ @service.send(method.to_sym, @service_result)
+end
+
+Then /^the save result should equal: "([^\"]*)"$/ do |result|
+ @saved_result.to_s.should == result
+end
+
+Then /^the method "([^\"]*)" on the save result should equal: "([^\"]*)"$/ do |method, value|
+ result = @saved_result.send(method.to_sym)
+ result.should == value
+end
+
+When /^blueprints exist for the service$/ do
+ require File.expand_path(File.dirname(__FILE__) + "../../../test/blueprints")
+end
+
+Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object it should throw an exception with message "([^\"]*)"$/ do |method, object, msg|
+ obj = object.constantize.send :make
+ lambda { @service.send(method.to_sym, obj) }.should raise_error(msg)
+end
+
+Then /^no "([^\"]*)" should exist$/ do |collection|
+ @service.send(collection)
+ results = @service.execute
+ results.should == []
+end
+
+Given /^the following (.*) exist:$/ do |plural_factory, table|
+ # table is a Cucumber::Ast::Table
+ factory = plural_factory.singularize
+ table.hashes.map do |hash|
+ obj = factory.constantize.send(:make, hash)
+ @service.send("AddTo#{plural_factory}", obj)
+ @service.save_changes
+ end
+end
+
+Given /^(\d+) (.*) exist$/ do |num, plural_factory|
+ factory = plural_factory.singularize
+ num.to_i.times do
+ obj = factory.constantize.send(:make)
+ @service.send("AddTo#{plural_factory}", obj)
+ end
+ @service.save_changes # Batch save
+end
+
+Then /^the result should be:$/ do |table|
+ # table is a Cucumber::Ast::Table
+
+ fields = table.hashes[0].keys
+
+ # Build an array of hashes so that we can compare tables
+ results = []
+
+ @service_result.each do |result|
+ obj_hash = Hash.new
+ fields.each do |field|
+ obj_hash[field] = result.send(field)
+ end
+ results << obj_hash
+ end
+
+ result_table = Cucumber::Ast::Table.new(results)
+
+ table.diff!(result_table)
+end
+
+Then /^the save result should be:$/ do |table|
+ # table is a Cucumber::Ast::Table
+
+ fields = table.hashes[0].keys
+
+ # Build an array of hashes so that we can compare tables
+ results = []
+
+ @saved_result.each do |result|
+ obj_hash = Hash.new
+ fields.each do |field|
+ obj_hash[field] = result.send(field)
+ end
+ results << obj_hash
+ end
+
+ result_table = Cucumber::Ast::Table.new(results)
+
+ table.diff!(result_table)
+end
+
+Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
+ (Object.const_defined? klass_name).should == true
+end
+
+# Operations against a method on the service result
+When /^I call "([^\"]*)" for "([^\"]*)" on the result$/ do |method2, method1|
+ r1 = @service_result.send(method1)
+ @operation_result = r1.send(method2)
+end
+
+Then /^the operation should not be null$/ do
+ @operation_result.nil?.should == false
+end
+
+
+Then /^the method "([^\"]*)" on the result's method "([^\"]*)" should equal: "([^\"]*)"$/ do |method, result_method, value|
+ obj = @service_result.send(result_method.to_sym)
+ obj.send(method.to_sym).to_s.should == value
+end
+
+When /^I set "([^\"]*)" on the result's method "([^\"]*)" to "([^\"]*)"$/ do |property_name, result_method, value|
+ @service_result.send(result_method).send("#{property_name}=", value)
+end
+
+# Type tests
+Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
+ methods = method_name.split '.'
+ if methods.length == 1
+ @service_result.send(method_name).class.to_s.should == type
+ else
+ @service_result.send(methods[0]).send(methods[1]).class.to_s.should == type
+ end
+
+end
+Then /^I store the last query result for comparison$/ do
+ @stored_query_result = @service_result
+end
+Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
+ methods = method_name.split '.'
+ if methods.length == 1
+ @service_result.send(method_name).xmlschema(3).should == @stored_query_result.send(method_name).xmlschema(3)
+ else
+ @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should == @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
+ end
end
View
8 features/support/env.rb
@@ -1,4 +1,4 @@
-require 'lib/ruby_odata'
-require 'machinist/object'
-require 'sham'
-require 'faker'
+require 'lib/ruby_odata'
+require 'machinist/object'
+require 'sham'
+require 'faker'
View
6 features/support/hooks.rb
@@ -1,4 +1,4 @@
-Before do
- Sham.reset
- RestClient.post "http://localhost:8888/SampleService/Entities.svc/CleanDatabaseForTesting", {}
+Before do
+ Sham.reset
+ RestClient.post "http://localhost:8888/SampleService/Entities.svc/CleanDatabaseForTesting", {}
end
View
90 features/type_conversion.feature
@@ -1,45 +1,45 @@
-Feature: Type conversion
- In order to accurately perform operations
- As a user of the API
- I want types returned to be accurately represented
-
-Background:
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
- And blueprints exist for the service
-
-Scenario: Integers should be Fixnums
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- When I call "Products" on the service
- And I run the query
- Then the "Id" method should return a Fixnum
-
-Scenario: Decimals should be BigDecimals
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- When I call "Products" on the service
- And I run the query
- Then the "Price" method should return a BigDecimal
-
-Scenario: DateTimes should be Times
- Given I call "AddToProducts" on the service with a new "Product" object
- And I save changes
- When I call "Products" on the service
- And I run the query
- Then the "AuditFields.CreateDate" method should return a Time
-
-Scenario: Verify that DateTimes don't change if not modified on an update
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
- When I save changes
- And I call "Products" on the service with args: "1"
- And I run the query
- Then I store the last query result for comparison
- When I set "Name" on the result to "Changed Test Product"
- Then the method "Name" on the result should equal: "Changed Test Product"
- And I call "update_object" on the service with the last query result
- And I save changes
- Then the save result should equal: "true"
- When I call "Products" on the service with args: "1"
- And I run the query
- Then the new query result's time "AuditFields.CreateDate" should equal the saved query result
-
+Feature: Type conversion
+ In order to accurately perform operations
+ As a user of the API
+ I want types returned to be accurately represented
+
+Background:
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
+ And blueprints exist for the service
+
+Scenario: Integers should be Fixnums
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ When I call "Products" on the service
+ And I run the query
+ Then the "Id" method should return a Fixnum
+
+Scenario: Decimals should be BigDecimals
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ When I call "Products" on the service
+ And I run the query
+ Then the "Price" method should return a BigDecimal
+
+Scenario: DateTimes should be Times
+ Given I call "AddToProducts" on the service with a new "Product" object
+ And I save changes
+ When I call "Products" on the service
+ And I run the query
+ Then the "AuditFields.CreateDate" method should return a Time
+
+Scenario: Verify that DateTimes don't change if not modified on an update
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
+ When I save changes
+ And I call "Products" on the service with args: "1"
+ And I run the query
+ Then I store the last query result for comparison
+ When I set "Name" on the result to "Changed Test Product"
+ Then the method "Name" on the result should equal: "Changed Test Product"
+ And I call "update_object" on the service with the last query result
+ And I save changes
+ Then the save result should equal: "true"
+ When I call "Products" on the service with args: "1"
+ And I run the query
+ Then the new query result's time "AuditFields.CreateDate" should equal the saved query result
+
View
212 lib/ruby_odata/query_builder.rb
@@ -1,107 +1,107 @@
-module OData
-# The query builder is used to call query operations against the service. This shouldn't be called directly, but rather it is returned from the dynamic methods created for the specific service that you are calling.
-#
-# For example, given the following code snippet:
-# svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc"
-# svc.Categories
-# The *Categories* method would return a QueryBuilder
-class QueryBuilder
- # Creates a new instance of the QueryBuilder class
- #
- # ==== Required Attributes
- # - root: The root entity collection to query against
- def initialize(root)
- @root = root.to_s
- @expands = []
- @filters = []
- @order_bys = []
- @skip = nil
- @top = nil
- end
-
- # Used to eagerly-load data for nested objects, for example, obtaining a Category for a Product within one call to the server
- # ==== Required Attributes
- # - path: The path of the entity to expand relative to the root
- #
- # ==== Example
- # # Without expanding the query (no Category will be filled in for the Product)
- # svc.Products(1)
- # prod1 = svc.execute
- #
- # # With expanding the query (the Category will be filled in)
- # svc.Products(1).expand('Category')
- # prod1 = svc.execute
- def expand(path)
- @expands << path
- self
- end
-
- # Used to filter data being returned
- # ==== Required Attributes
- # - filter: The conditions to apply to the query
- #
- # ==== Example
- # svc.Products.filter("Name eq 'Product 2'")
- # products = svc.execute
- def filter(filter)
- @filters << CGI.escape(filter)
- self
- end
-
- # Used to order the data being returned
- # ==== Required Attributes
- # - order_by: The order by statement. Note to specify direction, use "desc" or "asc"; must be lowercase
- #
- # ==== Example
- # svc.Products.order_by("Name")
- # products = svc.execute
- def order_by(order_by)
- @order_bys << CGI.escape(order_by)
- self
- end
-
- # Used to skip a number of records
- # This is typically used for paging, where it would be used along with the +top+ method.
- # ==== Required Attributes
- # - num: The number of items to skip
- #
- # ==== Example
- # svc.Products.skip(5)
- # products = svc.execute # => skips the first 5 items
- def skip(num)
- @skip = num
- self
- end
-
- # Used to take only the top X records
- # This is typically used for paging, where it would be used along with the +skip+ method.
- # ==== Required Attributes
- # - num: The number of items to return
- #
- # ==== Example
- # svc.Products.top(5)
- # products = svc.execute # => returns only the first 5 items
- def top(num)
- @top = num
- self
- end
-
- # Builds the query URI (path, not including root) incorporating expands, filters, etc.
- # This is used internally when the execute method is called on the service
- def query
- q = @root.clone
- query_options = []
- query_options << "$expand=#{@expands.join(',')}" unless @expands.empty?
- query_options << "$filter=#{@filters.join('+and+')}" unless @filters.empty?
- query_options << "$orderby=#{@order_bys.join(',')}" unless @order_bys.empty?
- query_options << "$skip=#{@skip}" unless @skip.nil?
- query_options << "$top=#{@top}" unless @top.nil?
- if !query_options.empty?
- q << "?"
- q << query_options.join('&')
- end
- return q
- end
-end
-
+module OData
+# The query builder is used to call query operations against the service. This shouldn't be called directly, but rather it is returned from the dynamic methods created for the specific service that you are calling.
+#
+# For example, given the following code snippet:
+# svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc"
+# svc.Categories
+# The *Categories* method would return a QueryBuilder
+class QueryBuilder
+ # Creates a new instance of the QueryBuilder class
+ #
+ # ==== Required Attributes
+ # - root: The root entity collection to query against
+ def initialize(root)
+ @root = root.to_s
+ @expands = []
+ @filters = []
+ @order_bys = []
+ @skip = nil
+ @top = nil
+ end
+
+ # Used to eagerly-load data for nested objects, for example, obtaining a Category for a Product within one call to the server
+ # ==== Required Attributes
+ # - path: The path of the entity to expand relative to the root
+ #
+ # ==== Example
+ # # Without expanding the query (no Category will be filled in for the Product)
+ # svc.Products(1)
+ # prod1 = svc.execute
+ #
+ # # With expanding the query (the Category will be filled in)
+ # svc.Products(1).expand('Category')
+ # prod1 = svc.execute
+ def expand(path)
+ @expands << path
+ self
+ end
+
+ # Used to filter data being returned
+ # ==== Required Attributes
+ # - filter: The conditions to apply to the query
+ #
+ # ==== Example
+ # svc.Products.filter("Name eq 'Product 2'")
+ # products = svc.execute
+ def filter(filter)
+ @filters << CGI.escape(filter)
+ self
+ end
+
+ # Used to order the data being returned
+ # ==== Required Attributes
+ # - order_by: The order by statement. Note to specify direction, use "desc" or "asc"; must be lowercase
+ #
+ # ==== Example
+ # svc.Products.order_by("Name")
+ # products = svc.execute
+ def order_by(order_by)
+ @order_bys << CGI.escape(order_by)
+ self
+ end
+
+ # Used to skip a number of records
+ # This is typically used for paging, where it would be used along with the +top+ method.
+ # ==== Required Attributes
+ # - num: The number of items to skip
+ #
+ # ==== Example
+ # svc.Products.skip(5)
+ # products = svc.execute # => skips the first 5 items
+ def skip(num)
+ @skip = num
+ self
+ end
+
+ # Used to take only the top X records
+ # This is typically used for paging, where it would be used along with the +skip+ method.
+ # ==== Required Attributes
+ # - num: The number of items to return
+ #
+ # ==== Example
+ # svc.Products.top(5)
+ # products = svc.execute # => returns only the first 5 items
+ def top(num)
+ @top = num
+ self
+ end
+
+ # Builds the query URI (path, not including root) incorporating expands, filters, etc.
+ # This is used internally when the execute method is called on the service
+ def query
+ q = @root.clone
+ query_options = []
+ query_options << "$expand=#{@expands.join(',')}" unless @expands.empty?
+ query_options << "$filter=#{@filters.join('+and+')}" unless @filters.empty?
+ query_options << "$orderby=#{@order_bys.join(',')}" unless @order_bys.empty?
+ query_options << "$skip=#{@skip}" unless @skip.nil?
+ query_options << "$top=#{@top}" unless @top.nil?
+ if !query_options.empty?
+ q << "?"
+ q << query_options.join('&')
+ end
+ return q
+ end
+end
+
end # Module
View
40 test/blueprints.rb
@@ -1,21 +1,21 @@
-Sham.define do
- category_name { |i| "Category #{i}" }
- product_name { |i| "Widget #{i}" }
- price(:unique => false) { ['5.00', '10.00', '20.00', '15.00' , '25.00', '7.50'].rand }
-end
-
-Product.blueprint do
- Name { Sham.product_name }
- Description "Test Widget"
- Price { Sham.price }
- Category { Category.make }
- AuditFields { AuditFields.make }
-end
-
-Category.blueprint do
- Name { Sham.category_name }
-end
-
-AuditFields.blueprint do
- CreatedBy "Cucumber"
+Sham.define do
+ category_name { |i| "Category #{i}" }
+ product_name { |i| "Widget #{i}" }
+ price(:unique => false) { ['5.00', '10.00', '20.00', '15.00' , '25.00', '7.50'].rand }
+end
+
+Product.blueprint do
+ Name { Sham.product_name }
+ Description "Test Widget"
+ Price { Sham.price }
+ Category { Category.make }
+ AuditFields { AuditFields.make }
+end
+
+Category.blueprint do
+ Name { Sham.category_name }
+end
+
+AuditFields.blueprint do
+ CreatedBy "Cucumber"
end
Please sign in to comment.
Something went wrong with that request. Please try again.