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.
@@ -1,49 +1,49 @@
1
- Feature: Service Should Generate a Proxy
2
- In order to consume the OData
3
- As a user
4
- I want to be able to access data
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: Service should respond to valid collections
11
- Then I should be able to call "Categories" on the service
12
-
13
- Scenario: Service should not respond to an invalid collection
14
- Then I should not be able to call "X" on the service
15
-
16
- Scenario: Service should respond to accessing a single entity by ID
17
- Then I should be able to call "Categories" on the service with args: "1"
18
-
19
- Scenario: Access an entity by ID should return the entity type
20
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
21
- And I save changes
22
- And I call "Categories" on the service with args: "1"
23
- When I run the query
24
- Then the result should be of type "Category"
25
-
26
- Scenario: Entity should have the correct accessors
27
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
28
- And I save changes
29
- And I call "Categories" on the service with args: "1"
30
- When I run the query
31
- Then the result should have a method: "Id"
32
- And the result should have a method: "Name"
33
-
34
- Scenario: Entity should fill values
35
- Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
36
- And I save changes
37
- And I call "Categories" on the service with args: "1"
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"
41
-
42
- Scenario: Navigation Properties should be included in results
43
- Given I call "AddToProducts" on the service with a new "Product" object
44
- And I save changes
45
- And I call "Products" on the service with args: "1"
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
49
-
1
+ Feature: Service Should Generate a Proxy
2
+ In order to consume the OData
3
+ As a user
4
+ I want to be able to access data
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: Service should respond to valid collections
11
+ Then I should be able to call "Categories" on the service
12
+
13
+ Scenario: Service should not respond to an invalid collection
14
+ Then I should not be able to call "X" on the service
15
+
16
+ Scenario: Service should respond to accessing a single entity by ID
17
+ Then I should be able to call "Categories" on the service with args: "1"
18
+
19
+ Scenario: Access an entity by ID should return the entity type
20
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
21
+ And I save changes
22
+ And I call "Categories" on the service with args: "1"
23
+ When I run the query
24
+ Then the result should be of type "Category"
25
+
26
+ Scenario: Entity should have the correct accessors
27
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
28
+ And I save changes
29
+ And I call "Categories" on the service with args: "1"
30
+ When I run the query
31
+ Then the result should have a method: "Id"
32
+ And the result should have a method: "Name"
33
+
34
+ Scenario: Entity should fill values
35
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
36
+ And I save changes
37
+ And I call "Categories" on the service with args: "1"
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"
41
+
42
+ Scenario: Navigation Properties should be included in results
43
+ Given I call "AddToProducts" on the service with a new "Product" object
44
+ And I save changes
45
+ And I call "Products" on the service with args: "1"
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
49
+
@@ -1,44 +1,54 @@
1
- Feature: Service management
2
- In order to manage entities
3
- As a admin
4
- I want to be able to add, edit, and delete entities
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: Service should respond to AddToEntityName for adding objects
11
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Sample Product"
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"
15
-
16
- Scenario: Service should allow for deletes
17
- Given I call "AddToProducts" on the service with a new "Product" object
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
21
- And I save changes
22
- Then the save result should equal: "true"
23
- And no "Products" should exist
24
-
25
- Scenario: Untracked entities shouldn't be able to be deleted
26
- 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"
27
-
28
- Scenario: Entities should be able to be updated
29
- Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
30
- When I save changes
31
- And I call "Products" on the service with args: "1"
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
37
- And I save changes
38
- Then the save result should equal: "true"
39
- When I call "Products" on the service with args: "1"
40
- And I run the query
41
- Then the method "Name" on the result should equal: "Changed Test Product"
42
-
43
- Scenario: Untracked entities shouldn't be able to be updated
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"
1
+ Feature: Service management
2
+ In order to manage entities
3
+ As a admin
4
+ I want to be able to add, edit, and delete entities
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: Service should respond to AddToEntityName for adding objects
11
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Sample Product"
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"
15
+
16
+ Scenario: Service should allow for deletes
17
+ Given I call "AddToProducts" on the service with a new "Product" object
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
21
+ And I save changes
22
+ Then the save result should equal: "true"
23
+ And no "Products" should exist
24
+
25
+ Scenario: Untracked entities shouldn't be able to be deleted
26
+ 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"
27
+
28
+ Scenario: Entities should be able to be updated
29
+ Given I call "AddToProducts" on the service with a new "Product" object with Name: "Test Product"
30
+ When I save changes
31
+ And I call "Products" on the service with args: "1"
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
37
+ And I save changes
38
+ Then the save result should equal: "true"
39
+ When I call "Products" on the service with args: "1"
40
+ And I run the query
41
+ Then the method "Name" on the result should equal: "Changed Test Product"
42
+
43
+ Scenario: Untracked entities shouldn't be able to be updated
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"
45
+
46
+ Scenario: Related entities shouldn't be recreated on a child add
47
+ Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
48
+ And I save changes
49
+ And I call "AddToProducts" on the service with a new "Product" object with Category: "@@LastSave"
50
+ And I save changes
51
+ And I call "Products" on the service with args: "1"
52
+ And I expand the query to include "Category"
53
+ When I run the query
54
+ Then the method "Id" on the result's method "Category" should equal: "1"
@@ -1,244 +1,256 @@
1
- Given /^an ODataService exists with uri: "([^\"]*)"$/ do |uri|
2
- @service = OData::Service.new(uri)
3
- end
4
-
5
- When /^I call "([^\"]*)" on the service$/ do |method|
6
- @service_query = @service.send(method)
7
- end
8
-
9
- Then /^the result should be "([^\"]*)"$/ do |result|
10
- @service_result.should == result
11
- end
12
-
13
- Then /^I should be able to call "([^\"]*)" on the service$/ do |method|
14
- lambda { @service.send(method) }.should_not raise_error
15
- end
16
-
17
- Then /^I should not be able to call "([^\"]*)" on the service$/ do |method|
18
- lambda { @service.send(method) }.should raise_error
19
- end
20
-
21
- Then /^I should be able to call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
22
- lambda { @service.send(method, args) }.should_not raise_error
23
- end
24
-
25
- When /^I call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
26
- @service_query = @service.send(method, args)
27
- end
28
-
29
- When /^I run the query$/ do
30
- @service_result = @service.execute
31
- end
32
-
33
- Then /^the result should be of type "([^\"]*)"$/ do |type|
34
- @service_result.class.to_s.should == type
35
- end
36
-
37
- Then /^the result should have a method: "([^\"]*)"$/ do |method|
38
- @service_result.respond_to?(method.to_sym).should == true
39
- end
40
-
41
- Then /^the method "([^\"]*)" on the result should equal: "([^\"]*)"$/ do |method, value|
42
- @service_result.send(method.to_sym).to_s.should == value
43
- end
44
-
45
- Then /^the method "([^\"]*)" on the result should be nil$/ do |method|
46
- @service_result.send(method.to_sym).should == nil
47
- end
48
-
49
- When /^I set "([^\"]*)" on the result to "([^\"]*)"$/ do |property_name, value|
50
- @service_result.send("#{property_name}=", value)
51
- end
52
-
53
- Given /^I expand the query to include "([^\"]*)"$/ do |expands|
54
- @service_query.expand(expands)
55
- end
56
-
57
- When /^I filter the query with: "([^\"]*)"$/ do |filter|
58
- @service_query.filter(filter)
59
- end
60
-
61
- When /^I order by: "([^\"]*)"$/ do |order|
62
- @service_query.order_by(order)
63
- end
64
-
65
- When /^I skip (\d+)$/ do |skip|
66
- @service_query.skip(skip)
67
- end
68
-
69
- When /^I ask for the top (\d+)$/ do |top|
70
- @service_query.top(top)
71
- end
72
-
73
- Then /^the method "([^\"]*)" on the result should be of type "([^\"]*)"$/ do |method, type|
74
- result = @service_result.send(method.to_sym)
75
- result.class.to_s.should == type
76
- end
77
-
78
- Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object(?: with (.*))?$/ do |method, object, fields|
79
- fields_hash = {}
80
-
81
- if !fields.nil?
82
- fields.split(', ').each do |field|
83
- if field =~ /^(?:(\w+): "(.*)")$/
84
- key = $1
85
- val = $2
86
- if val =~ /^@@LastSave$/
87
- val = @saved_result
88
- end
89
-
90
- fields_hash.merge!({ key => val })
91
- end
92
- end
93
- end
94
-
95
- obj = object.constantize.send(:make, fields_hash)
96
- @service.send(method.to_sym, obj)
97
- end
98
-
99
- When /^I save changes$/ do
100
- @saved_result = @service.save_changes
101
- end
102
-
103
- Then /^the save result should be of type "([^\"]*)"$/ do |type|
104
- @saved_result.class.to_s.should == type
105
- end
106
-
107
- When /^I call "([^\"]*)" on the service with the last save result$/ do |method|
108
- @service.send(method.to_sym, @saved_result)
109
- end
110
-
111
- When /^I call "([^\"]*)" on the service with the last query result$/ do |method|
112
- @service.send(method.to_sym, @service_result)
113
- end
114
-
115
- Then /^the save result should equal: "([^\"]*)"$/ do |result|
116
- @saved_result.to_s.should == result
117
- end
118
-
119
- Then /^the method "([^\"]*)" on the save result should equal: "([^\"]*)"$/ do |method, value|
120
- result = @saved_result.send(method.to_sym)
121
- result.should == value
122
- end
123
-
124
- When /^blueprints exist for the service$/ do
125
- require File.expand_path(File.dirname(__FILE__) + "../../../test/blueprints")
126
- end
127
-
128
- Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object it should throw an exception with message "([^\"]*)"$/ do |method, object, msg|
129
- obj = object.constantize.send :make
130
- lambda { @service.send(method.to_sym, obj) }.should raise_error(msg)
131
- end
132
-
133
- Then /^no "([^\"]*)" should exist$/ do |collection|
134
- @service.send(collection)
135
- results = @service.execute
136
- results.should == []
137
- end
138
-
139
- Given /^the following (.*) exist:$/ do |plural_factory, table|
140
- # table is a Cucumber::Ast::Table
141
- factory = plural_factory.singularize
142
- table.hashes.map do |hash|
143
- obj = factory.constantize.send(:make, hash)
144
- @service.send("AddTo#{plural_factory}", obj)
145
- @service.save_changes
146
- end
147
- end
148
-
149
- Given /^(\d+) (.*) exist$/ do |num, plural_factory|
150
- factory = plural_factory.singularize
151
- num.to_i.times do
152
- obj = factory.constantize.send(:make)
153
- @service.send("AddTo#{plural_factory}", obj)
154
- end
155
- @service.save_changes # Batch save
156
- end
157
-
158
- Then /^the result should be:$/ do |table|
159
- # table is a Cucumber::Ast::Table
160
-
161
- fields = table.hashes[0].keys
162
-
163
- # Build an array of hashes so that we can compare tables
164
- results = []
165
-
166
- @service_result.each do |result|
167
- obj_hash = Hash.new
168
- fields.each do |field|
169
- obj_hash[field] = result.send(field)
170
- end
171
- results << obj_hash
172
- end
173
-
174
- result_table = Cucumber::Ast::Table.new(results)
175
-
176
- table.diff!(result_table)
177
- end
178
-
179
- Then /^the save result should be:$/ do |table|
180
- # table is a Cucumber::Ast::Table
181
-
182
- fields = table.hashes[0].keys
183
-
184
- # Build an array of hashes so that we can compare tables
185
- results = []
186
-
187
- @saved_result.each do |result|
188
- obj_hash = Hash.new
189
- fields.each do |field|
190
- obj_hash[field] = result.send(field)
191
- end
192
- results << obj_hash
193
- end
194
-
195
- result_table = Cucumber::Ast::Table.new(results)
196
-
197
- table.diff!(result_table)
198
- end
199
-
200
- Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
201
- (Object.const_defined? klass_name).should == true
202
- end
203
-
204
- # Operations against a method on the service result
205
- When /^I call "([^\"]*)" for "([^\"]*)" on the result$/ do |method2, method1|
206
- r1 = @service_result.send(method1)
207
- @operation_result = r1.send(method2)
208
- end
209
-
210
- Then /^the operation should not be null$/ do
211
- @operation_result.nil?.should == false
212
- end
213
-
214
-
215
- Then /^the method "([^\"]*)" on the result's method "([^\"]*)" should equal: "([^\"]*)"$/ do |method, result_method, value|
216
- obj = @service_result.send(result_method.to_sym)
217
- obj.send(method.to_sym).to_s.should == value
218
- end
219
-
220
- When /^I set "([^\"]*)" on the result's method "([^\"]*)" to "([^\"]*)"$/ do |property_name, result_method, value|
221
- @service_result.send(result_method).send("#{property_name}=", value)
222
- end
223
-
224
- # Type tests
225
- Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
226
- methods = method_name.split '.'
227
- if methods.length == 1
228
- @service_result.send(method_name).class.to_s.should == type
229
- else
230
- @service_result.send(methods[0]).send(methods[1]).class.to_s.should == type
231
- end
232
-
233
- end
234
- Then /^I store the last query result for comparison$/ do
235
- @stored_query_result = @service_result
236
- end
237
- Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
238
- methods = method_name.split '.'
239
- if methods.length == 1
240
- @service_result.send(method_name).xmlschema(3).should == @stored_query_result.send(method_name).xmlschema(3)
241
- else
242
- @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should == @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
243
- end
1
+ Given /^an ODataService exists with uri: "([^\"]*)"$/ do |uri|
2
+ @service = OData::Service.new(uri)
3
+ end
4
+
5
+ Given /^an ODataService exists with uri: "([^\"]*)" using username "([^\"]*)" and password "([^\"]*)"$/ do |uri, username, password|
6
+ @service = OData::Service.new(uri, { :username => username, :password => password })
7
+ end
8
+
9
+ Given /^an ODataService exists with uri: "([^\"]*)" using username "([^\"]*)" and password "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |uri, username, password, msg|
10
+ lambda { @service = OData::Service.new(uri, { :username => username, :password => password }) }.should raise_error(msg)
11
+ end
12
+
13
+ Given /^an ODataService exists with uri: "([^\"]*)" it should throw an exception with message "([^\"]*)"$/ do |uri, msg|
14
+ lambda { @service = OData::Service.new(uri) }.should raise_error(msg)
15
+ end
16
+
17
+ When /^I call "([^\"]*)" on the service$/ do |method|
18
+ @service_query = @service.send(method)
19
+ end
20
+
21
+ Then /^the result should be "([^\"]*)"$/ do |result|
22
+ @service_result.should == result
23
+ end
24
+
25
+ Then /^I should be able to call "([^\"]*)" on the service$/ do |method|
26
+ lambda { @service.send(method) }.should_not raise_error
27
+ end
28
+
29
+ Then /^I should not be able to call "([^\"]*)" on the service$/ do |method|
30
+ lambda { @service.send(method) }.should raise_error
31
+ end
32
+
33
+ Then /^I should be able to call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
34
+ lambda { @service.send(method, args) }.should_not raise_error
35
+ end
36
+
37
+ When /^I call "([^\"]*)" on the service with args: "([^\"]*)"$/ do |method, args|
38
+ @service_query = @service.send(method, args)
39
+ end
40
+
41
+ When /^I run the query$/ do
42
+ @service_result = @service.execute
43
+ end
44
+
45
+ Then /^the result should be of type "([^\"]*)"$/ do |type|
46
+ @service_result.class.to_s.should == type
47
+ end
48
+
49
+ Then /^the result should have a method: "([^\"]*)"$/ do |method|
50
+ @service_result.respond_to?(method.to_sym).should == true
51
+ end
52
+
53
+ Then /^the method "([^\"]*)" on the result should equal: "([^\"]*)"$/ do |method, value|
54
+ @service_result.send(method.to_sym).to_s.should == value
55
+ end
56
+
57
+ Then /^the method "([^\"]*)" on the result should be nil$/ do |method|
58
+ @service_result.send(method.to_sym).should == nil
59
+ end
60
+
61
+ When /^I set "([^\"]*)" on the result to "([^\"]*)"$/ do |property_name, value|
62
+ @service_result.send("#{property_name}=", value)
63
+ end
64
+
65
+ Given /^I expand the query to include "([^\"]*)"$/ do |expands|
66
+ @service_query.expand(expands)
67
+ end
68
+
69
+ When /^I filter the query with: "([^\"]*)"$/ do |filter|
70
+ @service_query.filter(filter)
71
+ end
72
+
73
+ When /^I order by: "([^\"]*)"$/ do |order|
74
+ @service_query.order_by(order)
75
+ end
76
+
77
+ When /^I skip (\d+)$/ do |skip|
78
+ @service_query.skip(skip)
79
+ end
80
+
81
+ When /^I ask for the top (\d+)$/ do |top|
82
+ @service_query.top(top)
83
+ end
84
+
85
+ Then /^the method "([^\"]*)" on the result should be of type "([^\"]*)"$/ do |method, type|
86
+ result = @service_result.send(method.to_sym)
87
+ result.class.to_s.should == type
88
+ end
89
+
90
+ Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object(?: with (.*))?$/ do |method, object, fields|
91
+ fields_hash = {}
92
+
93
+ if !fields.nil?
94
+ fields.split(', ').each do |field|
95
+ if field =~ /^(?:(\w+): "(.*)")$/
96
+ key = $1
97
+ val = $2
98
+ if val =~ /^@@LastSave$/
99
+ val = @saved_result
100
+ end
101
+
102
+ fields_hash.merge!({ key => val })
103
+ end
104
+ end
105
+ end
106
+
107
+ obj = object.constantize.send(:make, fields_hash)
108
+ @service.send(method.to_sym, obj)
109
+ end
110
+
111
+ When /^I save changes$/ do
112
+ @saved_result = @service.save_changes
113
+ end
114
+
115
+ Then /^the save result should be of type "([^\"]*)"$/ do |type|
116
+ @saved_result.class.to_s.should == type
117
+ end
118
+
119
+ When /^I call "([^\"]*)" on the service with the last save result$/ do |method|
120
+ @service.send(method.to_sym, @saved_result)
121
+ end
122
+
123
+ When /^I call "([^\"]*)" on the service with the last query result$/ do |method|
124
+ @service.send(method.to_sym, @service_result)
125
+ end
126
+
127
+ Then /^the save result should equal: "([^\"]*)"$/ do |result|
128
+ @saved_result.to_s.should == result
129
+ end
130
+
131
+ Then /^the method "([^\"]*)" on the save result should equal: "([^\"]*)"$/ do |method, value|
132
+ result = @saved_result.send(method.to_sym)
133
+ result.should == value
134
+ end
135
+
136
+ When /^blueprints exist for the service$/ do
137
+ require File.expand_path(File.dirname(__FILE__) + "../../../test/blueprints")
138
+ end
139
+
140
+ Given /^I call "([^\"]*)" on the service with a new "([^\"]*)" object it should throw an exception with message "([^\"]*)"$/ do |method, object, msg|
141
+ obj = object.constantize.send :make
142
+ lambda { @service.send(method.to_sym, obj) }.should raise_error(msg)
143
+ end
144
+
145
+ Then /^no "([^\"]*)" should exist$/ do |collection|
146
+ @service.send(collection)
147
+ results = @service.execute
148
+ results.should == []
149
+ end
150
+
151
+ Given /^the following (.*) exist:$/ do |plural_factory, table|
152
+ # table is a Cucumber::Ast::Table
153
+ factory = plural_factory.singularize
154
+ table.hashes.map do |hash|
155
+ obj = factory.constantize.send(:make, hash)
156
+ @service.send("AddTo#{plural_factory}", obj)
157
+ @service.save_changes
158
+ end
159
+ end
160
+
161
+ Given /^(\d+) (.*) exist$/ do |num, plural_factory|
162
+ factory = plural_factory.singularize
163
+ num.to_i.times do
164
+ obj = factory.constantize.send(:make)
165
+ @service.send("AddTo#{plural_factory}", obj)
166
+ end
167
+ @service.save_changes # Batch save
168
+ end
169
+
170
+ Then /^the result should be:$/ do |table|
171
+ # table is a Cucumber::Ast::Table
172
+
173
+ fields = table.hashes[0].keys
174
+
175
+ # Build an array of hashes so that we can compare tables
176
+ results = []
177
+
178
+ @service_result.each do |result|
179
+ obj_hash = Hash.new
180
+ fields.each do |field|
181
+ obj_hash[field] = result.send(field)
182
+ end
183
+ results << obj_hash
184
+ end
185
+
186
+ result_table = Cucumber::Ast::Table.new(results)
187
+
188
+ table.diff!(result_table)
189
+ end
190
+
191
+ Then /^the save result should be:$/ do |table|
192
+ # table is a Cucumber::Ast::Table
193
+
194
+ fields = table.hashes[0].keys
195
+
196
+ # Build an array of hashes so that we can compare tables
197
+ results = []
198
+
199
+ @saved_result.each do |result|
200
+ obj_hash = Hash.new
201
+ fields.each do |field|
202
+ obj_hash[field] = result.send(field)
203
+ end
204
+ results << obj_hash
205
+ end
206
+
207
+ result_table = Cucumber::Ast::Table.new(results)
208
+
209
+ table.diff!(result_table)
210
+ end
211
+
212
+ Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
213
+ (Object.const_defined? klass_name).should == true
214
+ end
215
+
216
+ # Operations against a method on the service result
217
+ When /^I call "([^\"]*)" for "([^\"]*)" on the result$/ do |method2, method1|
218
+ r1 = @service_result.send(method1)
219
+ @operation_result = r1.send(method2)
220
+ end
221
+
222
+ Then /^the operation should not be null$/ do
223
+ @operation_result.nil?.should == false
224
+ end
225
+
226
+
227
+ Then /^the method "([^\"]*)" on the result's method "([^\"]*)" should equal: "([^\"]*)"$/ do |method, result_method, value|
228
+ obj = @service_result.send(result_method.to_sym)
229
+ obj.send(method.to_sym).to_s.should == value
230
+ end
231
+
232
+ When /^I set "([^\"]*)" on the result's method "([^\"]*)" to "([^\"]*)"$/ do |property_name, result_method, value|
233
+ @service_result.send(result_method).send("#{property_name}=", value)
234
+ end
235
+
236
+ # Type tests
237
+ Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
238
+ methods = method_name.split '.'
239
+ if methods.length == 1
240
+ @service_result.send(method_name).class.to_s.should == type
241
+ else
242
+ @service_result.send(methods[0]).send(methods[1]).class.to_s.should == type
243
+ end
244
+
245
+ end
246
+ Then /^I store the last query result for comparison$/ do
247
+ @stored_query_result = @service_result
248
+ end
249
+ Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
250
+ methods = method_name.split '.'
251
+ if methods.length == 1
252
+ @service_result.send(method_name).xmlschema(3).should == @stored_query_result.send(method_name).xmlschema(3)
253
+ else
254
+ @service_result.send(methods[0]).send(methods[1]).xmlschema(3).should == @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
255
+ end
244
256
  end