ruby_odata 0.0.7 → 0.0.8

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.
data/Rakefile CHANGED
@@ -1,28 +1,10 @@
1
- require 'rake/rdoctask'
2
- Rake::RDocTask.new do |rd|
3
- rd.main = "README.rdoc"
4
- rd.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb")
5
- rd.rdoc_dir = 'doc'
6
- end
7
-
8
- begin
9
- require 'jeweler'
10
- Jeweler::Tasks.new do |gemspec|
11
- gemspec.name = "ruby_odata"
12
- gemspec.summary = "Ruby consumer of OData services."
13
- gemspec.description = "An OData Client Library for Ruby. Use this to interact with OData services"
14
- gemspec.email = "damien.white@visoftinc.com"
15
- gemspec.homepage = "http://github.com/visoft/ruby_odata"
16
- gemspec.authors = ["Damien White"]
17
- gemspec.add_dependency('activesupport', '>= 2.3.5')
18
- gemspec.add_dependency('rest-client', '>= 1.5.1')
19
- gemspec.add_dependency('nokogiri', '>= 1.4.2')
20
- gemspec.rubyforge_project = 'ruby-odata'
21
- end
22
- Jeweler::GemcutterTasks.new
23
- Jeweler::RubyforgeTasks.new do |rubyforge|
24
- rubyforge.doc_task = "rdoc"
25
- end
26
- rescue LoadError
27
- puts "Jeweler not available. Install it with: gem install jeweler"
28
- end
1
+ require 'rake/rdoctask'
2
+ require 'bundler'
3
+
4
+ Rake::RDocTask.new do |rd|
5
+ rd.main = "README.rdoc"
6
+ rd.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb")
7
+ rd.rdoc_dir = 'doc'
8
+ end
9
+
10
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ Feature: Service Should Access Basic Auth Protected Resources
2
+
3
+ Background:
4
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/BasicAuth/Entities.svc" using username "admin" and password "passwd"
5
+ And blueprints exist for the service
6
+
7
+ Scenario: Service should respond to valid collections
8
+ Then I should be able to call "Products" on the service
9
+
10
+ Scenario: Entity should fill values on protected resource
11
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Auth Test Category"
12
+ And I save changes
13
+ And I call "Categories" on the service with args: "1"
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"
17
+
18
+ Scenario: Should get 401 if invalid credentials provided to protected URL
19
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/BasicAuth/Entities.svc" using username "admin" and password "bad_pwd" it should throw an exception with message "401 Unauthorized"
20
+
21
+ Scenario: Should get 401 if no credentials provided to protected URL
22
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/BasicAuth/Entities.svc" it should throw an exception with message "401 Unauthorized"
23
+
24
+
@@ -1,94 +1,94 @@
1
- Feature: Batch request
2
- In order to minimize network traffic
3
- As a user of the library
4
- I want to be able to batch changes (Add/Update/Delete) and persist the batch instead of one at a time
5
-
6
- Background:
7
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
8
- And blueprints exist for the service
9
-
10
- Scenario: Save Changes should allow for batch additions
11
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
12
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
13
- When I save changes
14
- Then the save result should equal: "true"
15
- When I call "Products" on the service
16
- And I order by: "Name"
17
- And I run the query
18
- Then the result should be:
19
- | Name |
20
- | Product 1 |
21
- | Product 2 |
22
-
23
- Scenario: Save Changes should allow for batch updates
24
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
25
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
26
- When I save changes
27
- When I call "Products" on the service
28
- And I filter the query with: "Name eq 'Product 1'"
29
- And I run the query
30
- And I set "Name" on the result to "Product 1 - Updated"
31
- And I call "update_object" on the service with the last query result
32
- When I call "Products" on the service
33
- And I filter the query with: "Name eq 'Product 2'"
34
- And I run the query
35
- And I set "Name" on the result to "Product 2 - Updated"
36
- And I call "update_object" on the service with the last query result
37
- When I save changes
38
- When I call "Products" on the service
39
- And I order by: "Name"
40
- And I run the query
41
- Then the result should be:
42
- | Name |
43
- | Product 1 - Updated |
44
- | Product 2 - Updated |
45
-
46
- Scenario: Save Changes should allow for batch deletes
47
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
48
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
49
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
50
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
51
- When I save changes
52
- When I call "Products" on the service
53
- And I filter the query with: "Name eq 'Product 2'"
54
- And I run the query
55
- And I call "delete_object" on the service with the last query result
56
- When I call "Products" on the service
57
- And I filter the query with: "Name eq 'Product 3'"
58
- And I run the query
59
- And I call "delete_object" on the service with the last query result
60
- When I save changes
61
- When I call "Products" on the service
62
- And I order by: "Name"
63
- And I run the query
64
- Then the result should be:
65
- | Name |
66
- | Product 1 |
67
- | Product 4 |
68
-
69
- Scenario: Save Changes should allow for a mix of adds, updates, and deletes to be batched
70
- Given the following Products exist:
71
- | Name |
72
- | Product 1 |
73
- | Product 2 |
74
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
75
- And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
76
- When I call "Products" on the service
77
- And I filter the query with: "Name eq 'Product 1'"
78
- And I run the query
79
- And I set "Name" on the result to "Product 1 - Updated"
80
- And I call "update_object" on the service with the last query result
81
- When I call "Products" on the service
82
- And I filter the query with: "Name eq 'Product 2'"
83
- And I run the query
84
- And I call "delete_object" on the service with the last query result
85
- When I save changes
86
- When I call "Products" on the service
87
- And I order by: "Name"
88
- And I run the query
89
- Then the result should be:
90
- | Name |
91
- | Product 1 - Updated |
92
- | Product 3 |
93
- | Product 4 |
94
-
1
+ Feature: Batch request
2
+ In order to minimize network traffic
3
+ As a user of the library
4
+ I want to be able to batch changes (Add/Update/Delete) and persist the batch instead of one at a time
5
+
6
+ Background:
7
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
8
+ And blueprints exist for the service
9
+
10
+ Scenario: Save Changes should allow for batch additions
11
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
12
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
13
+ When I save changes
14
+ Then the save result should equal: "true"
15
+ When I call "Products" on the service
16
+ And I order by: "Name"
17
+ And I run the query
18
+ Then the result should be:
19
+ | Name |
20
+ | Product 1 |
21
+ | Product 2 |
22
+
23
+ Scenario: Save Changes should allow for batch updates
24
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
25
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
26
+ When I save changes
27
+ When I call "Products" on the service
28
+ And I filter the query with: "Name eq 'Product 1'"
29
+ And I run the query
30
+ And I set "Name" on the result to "Product 1 - Updated"
31
+ And I call "update_object" on the service with the last query result
32
+ When I call "Products" on the service
33
+ And I filter the query with: "Name eq 'Product 2'"
34
+ And I run the query
35
+ And I set "Name" on the result to "Product 2 - Updated"
36
+ And I call "update_object" on the service with the last query result
37
+ When I save changes
38
+ When I call "Products" on the service
39
+ And I order by: "Name"
40
+ And I run the query
41
+ Then the result should be:
42
+ | Name |
43
+ | Product 1 - Updated |
44
+ | Product 2 - Updated |
45
+
46
+ Scenario: Save Changes should allow for batch deletes
47
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Product 1"
48
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 2"
49
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
50
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
51
+ When I save changes
52
+ When I call "Products" on the service
53
+ And I filter the query with: "Name eq 'Product 2'"
54
+ And I run the query
55
+ And I call "delete_object" on the service with the last query result
56
+ When I call "Products" on the service
57
+ And I filter the query with: "Name eq 'Product 3'"
58
+ And I run the query
59
+ And I call "delete_object" on the service with the last query result
60
+ When I save changes
61
+ When I call "Products" on the service
62
+ And I order by: "Name"
63
+ And I run the query
64
+ Then the result should be:
65
+ | Name |
66
+ | Product 1 |
67
+ | Product 4 |
68
+
69
+ Scenario: Save Changes should allow for a mix of adds, updates, and deletes to be batched
70
+ Given the following Products exist:
71
+ | Name |
72
+ | Product 1 |
73
+ | Product 2 |
74
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 3"
75
+ And I call "AddToProducts" on the service with a new "Product" object with Name: "Product 4"
76
+ When I call "Products" on the service
77
+ And I filter the query with: "Name eq 'Product 1'"
78
+ And I run the query
79
+ And I set "Name" on the result to "Product 1 - Updated"
80
+ And I call "update_object" on the service with the last query result
81
+ When I call "Products" on the service
82
+ And I filter the query with: "Name eq 'Product 2'"
83
+ And I run the query
84
+ And I call "delete_object" on the service with the last query result
85
+ When I save changes
86
+ When I call "Products" on the service
87
+ And I order by: "Name"
88
+ And I run the query
89
+ Then the result should be:
90
+ | Name |
91
+ | Product 1 - Updated |
92
+ | Product 3 |
93
+ | Product 4 |
94
+
@@ -1,52 +1,52 @@
1
- Feature: Complex types
2
- In order to fully support OData services
3
- As a user of ruby_odata
4
- I want to be able to manage objects with complex types
5
-
6
- Background:
7
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
8
- And blueprints exist for the service
9
-
10
- Scenario: The proxy must generate classes for complex types if they exist
11
- Then a class named "AuditFields" should exist
12
-
13
- Scenario: Complex properties on an entity must be the correct type
14
- Given I call "AddToProducts" on the service with a new "Product" object
15
- And I save changes
16
- And I call "Products" on the service with args: "1"
17
- When I run the query
18
- Then the result should have a method: "AuditFields"
19
- And the method "AuditFields" on the result should be of type "AuditFields"
20
-
21
- Scenario: Complex properties on an entity must be filled
22
- Given I call "AddToProducts" on the service with a new "Product" object
23
- And I save changes
24
- And I call "Products" on the service with args: "1"
25
- When I run the query
26
- Then the result should have a method: "AuditFields"
27
- When I call "CreateDate" for "AuditFields" on the result
28
- Then the operation should not be null
29
-
30
- # TODO: This scenario should have the AuditFields.CreatedBy field set in the Given
31
- # instead it is set by the blueprint
32
- Scenario: Complex properties should be able to be added
33
- Given I call "AddToProducts" on the service with a new "Product" object
34
- And I save changes
35
- And I call "Products" on the service with args: "1"
36
- When I run the query
37
- Then the method "CreatedBy" on the result's method "AuditFields" should equal: "Cucumber"
38
-
39
- Scenario: Complex propertis should be able to be updated
40
- Given I call "AddToProducts" on the service with a new "Product" object
41
- And I save changes
42
- And I call "Products" on the service with args: "1"
43
- When I run the query
44
- When I set "CreatedBy" on the result's method "AuditFields" to "This Test"
45
- And I call "update_object" on the service with the last query result
46
- And I save changes
47
- Then the save result should equal: "true"
48
- When I call "Products" on the service with args: "1"
49
- And I run the query
50
- Then the method "CreatedBy" on the result's method "AuditFields" should equal: "This Test"
51
-
52
-
1
+ Feature: Complex types
2
+ In order to fully support OData services
3
+ As a user of ruby_odata
4
+ I want to be able to manage objects with complex types
5
+
6
+ Background:
7
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
8
+ And blueprints exist for the service
9
+
10
+ Scenario: The proxy must generate classes for complex types if they exist
11
+ Then a class named "AuditFields" should exist
12
+
13
+ Scenario: Complex properties on an entity must be the correct type
14
+ Given I call "AddToProducts" on the service with a new "Product" object
15
+ And I save changes
16
+ And I call "Products" on the service with args: "1"
17
+ When I run the query
18
+ Then the result should have a method: "AuditFields"
19
+ And the method "AuditFields" on the result should be of type "AuditFields"
20
+
21
+ Scenario: Complex properties on an entity must be filled
22
+ Given I call "AddToProducts" on the service with a new "Product" object
23
+ And I save changes
24
+ And I call "Products" on the service with args: "1"
25
+ When I run the query
26
+ Then the result should have a method: "AuditFields"
27
+ When I call "CreateDate" for "AuditFields" on the result
28
+ Then the operation should not be null
29
+
30
+ # TODO: This scenario should have the AuditFields.CreatedBy field set in the Given
31
+ # instead it is set by the blueprint
32
+ Scenario: Complex properties should be able to be added
33
+ Given I call "AddToProducts" on the service with a new "Product" object
34
+ And I save changes
35
+ And I call "Products" on the service with args: "1"
36
+ When I run the query
37
+ Then the method "CreatedBy" on the result's method "AuditFields" should equal: "Cucumber"
38
+
39
+ Scenario: Complex propertis should be able to be updated
40
+ Given I call "AddToProducts" on the service with a new "Product" object
41
+ And I save changes
42
+ And I call "Products" on the service with args: "1"
43
+ When I run the query
44
+ When I set "CreatedBy" on the result's method "AuditFields" to "This Test"
45
+ And I call "update_object" on the service with the last query result
46
+ And I save changes
47
+ Then the save result should equal: "true"
48
+ When I call "Products" on the service with args: "1"
49
+ And I run the query
50
+ Then the method "CreatedBy" on the result's method "AuditFields" should equal: "This Test"
51
+
52
+
@@ -1,153 +1,153 @@
1
- Feature: Query Builder
2
- In order to query OData services
3
- As a user
4
- I want to be able to perform valid OData protocol operations
5
-
6
- Background:
7
- Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
8
- And blueprints exist for the service
9
-
10
- # Expand
11
- Scenario: Navigation Properties should be able to be eager loaded
12
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
13
- And I save changes
14
- And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave"
15
- And I save changes
16
- And I call "Products" on the service with args: "1"
17
- And I expand the query to include "Category"
18
- When I run the query
19
- Then the method "Category" on the result should be of type "Category"
20
- And the method "Name" on the result's method "Category" should equal: "Test Category"
21
- And the method "Id" on the result's method "Category" should equal: "1"
22
-
23
-
24
- # Filters
25
- Scenario: Filters should be allowed on the root level entity
26
- # Filter
27
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
28
- When I save changes
29
- When I call "Products" on the service
30
- And I filter the query with: "Name eq 'Test Product'"
31
- And I run the query
32
- Then the method "Name" on the result should equal: "Test Product"
33
-
34
-
35
- # Order By
36
- Scenario: Order by should be allowed on the root level entity
37
- Given the following Products exist:
38
- | Name |
39
- | Product 2 |
40
- | Product 4 |
41
- | Product 5 |
42
- | Product 1 |
43
- | Product 3 |
44
- When I call "Products" on the service
45
- And I order by: "Name"
46
- And I run the query
47
- Then the result should be:
48
- | Name |
49
- | Product 1 |
50
- | Product 2 |
51
- | Product 3 |
52
- | Product 4 |
53
- | Product 5 |
54
-
55
- Scenario: Order by should accept sorting descending
56
- Given the following Products exist:
57
- | Name |
58
- | Product 2 |
59
- | Product 4 |
60
- | Product 5 |
61
- | Product 1 |
62
- | Product 3 |
63
- When I call "Products" on the service
64
- And I order by: "Name desc"
65
- And I run the query
66
- Then the result should be:
67
- | Name |
68
- | Product 5 |
69
- | Product 4 |
70
- | Product 3 |
71
- | Product 2 |
72
- | Product 1 |
73
-
74
- Scenario: Order by should access sorting acsending
75
- Given the following Products exist:
76
- | Name |
77
- | Product 2 |
78
- | Product 4 |
79
- | Product 5 |
80
- | Product 1 |
81
- | Product 3 |
82
- When I call "Products" on the service
83
- And I order by: "Name asc"
84
- And I run the query
85
- Then the result should be:
86
- | Name |
87
- | Product 1 |
88
- | Product 2 |
89
- | Product 3 |
90
- | Product 4 |
91
- | Product 5 |
92
-
93
-
94
- # Skip
95
- Scenario: Skip should be allowed on the root level entity
96
- Given the following Products exist:
97
- | Name |
98
- | Product 1 |
99
- | Product 2 |
100
- | Product 3 |
101
- | Product 4 |
102
- | Product 5 |
103
- When I call "Products" on the service
104
- And I skip 3
105
- And I run the query
106
- Then the result should be:
107
- | Name |
108
- | Product 4 |
109
- | Product 5 |
110
-
111
-
112
- # Top
113
- Scenario: Top should be allowed on the root level entity
114
- Given the following Products exist:
115
- | Name |
116
- | Product 1 |
117
- | Product 2 |
118
- | Product 3 |
119
- | Product 4 |
120
- | Product 5 |
121
- When I call "Products" on the service
122
- And I ask for the top 3
123
- And I run the query
124
- Then the result should be:
125
- | Name |
126
- | Product 1 |
127
- | Product 2 |
128
- | Product 3 |
129
-
130
- Scenario: Top should be able to be used along with skip for paging
131
- Given the following Products exist:
132
- | Name |
133
- | Product 1 |
134
- | Product 2 |
135
- | Product 3 |
136
- | Product 4 |
137
- | Product 5 |
138
- | Product 6 |
139
- When I call "Products" on the service
140
- And I skip 2
141
- And I ask for the top 2
142
- And I run the query
143
- Then the result should be:
144
- | Name |
145
- | Product 3 |
146
- | Product 4 |
147
-
148
-
149
-
150
-
151
-
152
-
153
-
1
+ Feature: Query Builder
2
+ In order to query OData services
3
+ As a user
4
+ I want to be able to perform valid OData protocol operations
5
+
6
+ Background:
7
+ Given an ODataService exists with uri: "http://localhost:8888/SampleService/Entities.svc"
8
+ And blueprints exist for the service
9
+
10
+ # Expand
11
+ Scenario: Navigation Properties should be able to be eager loaded
12
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
13
+ And I save changes
14
+ And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave"
15
+ And I save changes
16
+ And I call "Products" on the service with args: "1"
17
+ And I expand the query to include "Category"
18
+ When I run the query
19
+ Then the method "Category" on the result should be of type "Category"
20
+ And the method "Name" on the result's method "Category" should equal: "Test Category"
21
+ And the method "Id" on the result's method "Category" should equal: "1"
22
+
23
+
24
+ # Filters
25
+ Scenario: Filters should be allowed on the root level entity
26
+ # Filter
27
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
28
+ When I save changes
29
+ When I call "Products" on the service
30
+ And I filter the query with: "Name eq 'Test Product'"
31
+ And I run the query
32
+ Then the method "Name" on the result should equal: "Test Product"
33
+
34
+
35
+ # Order By
36
+ Scenario: Order by should be allowed on the root level entity
37
+ Given the following Products exist:
38
+ | Name |
39
+ | Product 2 |
40
+ | Product 4 |
41
+ | Product 5 |
42
+ | Product 1 |
43
+ | Product 3 |
44
+ When I call "Products" on the service
45
+ And I order by: "Name"
46
+ And I run the query
47
+ Then the result should be:
48
+ | Name |
49
+ | Product 1 |
50
+ | Product 2 |
51
+ | Product 3 |
52
+ | Product 4 |
53
+ | Product 5 |
54
+
55
+ Scenario: Order by should accept sorting descending
56
+ Given the following Products exist:
57
+ | Name |
58
+ | Product 2 |
59
+ | Product 4 |
60
+ | Product 5 |
61
+ | Product 1 |
62
+ | Product 3 |
63
+ When I call "Products" on the service
64
+ And I order by: "Name desc"
65
+ And I run the query
66
+ Then the result should be:
67
+ | Name |
68
+ | Product 5 |
69
+ | Product 4 |
70
+ | Product 3 |
71
+ | Product 2 |
72
+ | Product 1 |
73
+
74
+ Scenario: Order by should access sorting acsending
75
+ Given the following Products exist:
76
+ | Name |
77
+ | Product 2 |
78
+ | Product 4 |
79
+ | Product 5 |
80
+ | Product 1 |
81
+ | Product 3 |
82
+ When I call "Products" on the service
83
+ And I order by: "Name asc"
84
+ And I run the query
85
+ Then the result should be:
86
+ | Name |
87
+ | Product 1 |
88
+ | Product 2 |
89
+ | Product 3 |
90
+ | Product 4 |
91
+ | Product 5 |
92
+
93
+
94
+ # Skip
95
+ Scenario: Skip should be allowed on the root level entity
96
+ Given the following Products exist:
97
+ | Name |
98
+ | Product 1 |
99
+ | Product 2 |
100
+ | Product 3 |
101
+ | Product 4 |
102
+ | Product 5 |
103
+ When I call "Products" on the service
104
+ And I skip 3
105
+ And I run the query
106
+ Then the result should be:
107
+ | Name |
108
+ | Product 4 |
109
+ | Product 5 |
110
+
111
+
112
+ # Top
113
+ Scenario: Top should be allowed on the root level entity
114
+ Given the following Products exist:
115
+ | Name |
116
+ | Product 1 |
117
+ | Product 2 |
118
+ | Product 3 |
119
+ | Product 4 |
120
+ | Product 5 |
121
+ When I call "Products" on the service
122
+ And I ask for the top 3
123
+ And I run the query
124
+ Then the result should be:
125
+ | Name |
126
+ | Product 1 |
127
+ | Product 2 |
128
+ | Product 3 |
129
+
130
+ Scenario: Top should be able to be used along with skip for paging
131
+ Given the following Products exist:
132
+ | Name |
133
+ | Product 1 |
134
+ | Product 2 |
135
+ | Product 3 |
136
+ | Product 4 |
137
+ | Product 5 |
138
+ | Product 6 |
139
+ When I call "Products" on the service
140
+ And I skip 2
141
+ And I ask for the top 2
142
+ And I run the query
143
+ Then the result should be:
144
+ | Name |
145
+ | Product 3 |
146
+ | Product 4 |
147
+
148
+
149
+
150
+
151
+
152
+
153
+