melomel 0.6.4 → 0.6.5
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/CHANGELOG +3 -0
- data/lib/melomel/cucumber/data_grid_steps.rb +19 -39
- data/lib/melomel/cucumber.rb +117 -2
- data/lib/melomel/version.rb +1 -1
- metadata +13 -2
data/CHANGELOG
CHANGED
@@ -3,27 +3,9 @@ When /^I select "([^"]*)" on the "([^"]*)" data grid$/ do |value, name|
|
|
3
3
|
classes = Melomel::Flex.get_component_classes('data grid')
|
4
4
|
grid = Melomel::Cucumber.find_labeled!(classes, name)
|
5
5
|
grid.setFocus()
|
6
|
-
|
7
|
-
# Retrieve data and take off header row
|
8
|
-
data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
|
9
|
-
|
10
|
-
# Loop data and check for matches
|
11
|
-
index = nil
|
12
|
-
data.each_index do |i|
|
13
|
-
row = data[i]
|
14
|
-
row.each do |cell|
|
15
|
-
if (cell != nil) && (cell.strip == value)
|
16
|
-
index = i
|
17
|
-
break
|
18
|
-
end
|
19
|
-
end
|
20
6
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# If we couldn't find a matching cell then throw an error
|
25
|
-
raise "Cannot find '#{value}' on data grid" if index.nil?
|
26
|
-
|
7
|
+
index = Melomel::Cucumber.find_grid_index_by_label(grid, value)
|
8
|
+
|
27
9
|
grid.selectedIndex = index
|
28
10
|
end
|
29
11
|
end
|
@@ -35,23 +17,8 @@ Then /^I should see "([^"]*)" selected on the "([^"]*)" data grid$/ do |value, n
|
|
35
17
|
grid = Melomel::Cucumber.find_labeled!(classes, name)
|
36
18
|
grid.setFocus()
|
37
19
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# Loop data and check for matches
|
42
|
-
index = nil
|
43
|
-
data.each_index do |i|
|
44
|
-
row = data[i]
|
45
|
-
row.each do |cell|
|
46
|
-
if (cell != nil) && (cell.strip == value)
|
47
|
-
index = i
|
48
|
-
break
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
break unless index.nil?
|
53
|
-
end
|
54
|
-
|
20
|
+
index = Melomel::Cucumber.find_grid_index_by_label(grid, value)
|
21
|
+
|
55
22
|
grid.selectedIndex.should == index
|
56
23
|
end
|
57
24
|
end
|
@@ -63,7 +30,7 @@ Then /^I should see the following data in the "([^"]*)" data grid:$/ do |name, t
|
|
63
30
|
grid.setFocus()
|
64
31
|
|
65
32
|
data = Melomel::Cucumber.get_grid_data(grid)
|
66
|
-
|
33
|
+
|
67
34
|
table.diff!(data)
|
68
35
|
end
|
69
36
|
end
|
@@ -77,7 +44,20 @@ Then /^I should see no data in the "([^"]*)" data grid$/ do |name|
|
|
77
44
|
|
78
45
|
# Retrieve data and take off header row
|
79
46
|
data = Melomel::Cucumber.get_grid_data(grid)[1..-1]
|
80
|
-
|
47
|
+
|
81
48
|
data.size.should == 0
|
82
49
|
end
|
83
50
|
end
|
51
|
+
|
52
|
+
|
53
|
+
When /^I (open|close) "([^"]*)" on the "([^"]*)" data grid$/ do |action, value, name|
|
54
|
+
Melomel::Cucumber.run! do
|
55
|
+
classes = Melomel::Flex.get_component_classes('data grid')
|
56
|
+
grid = Melomel::Cucumber.find_labeled!(classes, name)
|
57
|
+
grid.setFocus()
|
58
|
+
|
59
|
+
element = Melomel::Cucumber.find_grid_element_by_label(grid, value)
|
60
|
+
|
61
|
+
grid.expandItem(element,action == "open")
|
62
|
+
end
|
63
|
+
end
|
data/lib/melomel/cucumber.rb
CHANGED
@@ -110,16 +110,91 @@ module Melomel
|
|
110
110
|
#
|
111
111
|
# Returns a 2D array of rows of columns of data.
|
112
112
|
def self.get_grid_data(grid)
|
113
|
+
data_with_elements = get_grid_data_with_elements(grid)
|
114
|
+
|
115
|
+
# Remove data grid elements
|
116
|
+
data_with_elements.map{|row| row[1..-1]}
|
117
|
+
end
|
118
|
+
|
119
|
+
# Retrieves the first element of a grid, which matches the label
|
120
|
+
#
|
121
|
+
# label - The label that should be found in the grid
|
122
|
+
# grid - The grid which will be searched in
|
123
|
+
#
|
124
|
+
# Returns the matched element
|
125
|
+
def self.find_grid_element_by_label(grid, label)
|
126
|
+
data_with_elements = get_grid_data_with_elements(grid)
|
127
|
+
|
128
|
+
# Remove data grid elements and first row
|
129
|
+
data = data_with_elements.map{|row| row[1..-1]}[1..-1]
|
130
|
+
|
131
|
+
index = find_index_by_label(data, label)
|
132
|
+
|
133
|
+
data_with_elements[index + 1].first
|
134
|
+
end
|
135
|
+
|
136
|
+
# Retrieves the index of the first element of a grid, which matches the label
|
137
|
+
#
|
138
|
+
# label - The label that should be found in the grid
|
139
|
+
# grid - The grid which will be searched in
|
140
|
+
#
|
141
|
+
# Returns the matched elements index
|
142
|
+
def self.find_grid_index_by_label(grid, label)
|
143
|
+
data_with_elements = get_grid_data_with_elements(grid)
|
144
|
+
|
145
|
+
# Remove data grid elements and first row
|
146
|
+
data = data_with_elements.map{|row| row[1..-1]}[1..-1]
|
147
|
+
|
148
|
+
index = find_index_by_label(data, label)
|
149
|
+
index
|
150
|
+
end
|
151
|
+
|
152
|
+
# Retrieves grid data as a 2D array of rows of columns. The first row
|
153
|
+
# contains the grid's header. The first column contains the grids elements.
|
154
|
+
#
|
155
|
+
# grid - The grid to generate the table from.
|
156
|
+
#
|
157
|
+
# Returns a 2D array of rows of columns of data.
|
158
|
+
def self.get_grid_data_with_elements(grid)
|
113
159
|
# Retrieve as columns of rows
|
114
160
|
data = []
|
161
|
+
group_labels = []
|
162
|
+
|
163
|
+
# Add the empty cell in the upper left corner
|
164
|
+
data << [nil]
|
165
|
+
|
166
|
+
# Retrieve data with cursor and group labels
|
167
|
+
i = 0
|
168
|
+
elements = get_grid_elements(grid)
|
169
|
+
elements.each do |element|
|
170
|
+
data[0] << element
|
171
|
+
if !element.GroupLabel.nil? && element.GroupLabel != ""
|
172
|
+
group_labels[i] = element.GroupLabel
|
173
|
+
end
|
174
|
+
i += 1
|
175
|
+
end
|
176
|
+
|
115
177
|
grid.columns.length.times do |i|
|
116
178
|
column_data = []
|
117
179
|
column = grid.columns[i]
|
118
|
-
labels = Melomel.items_to_labels!(column,
|
180
|
+
labels = Melomel.items_to_labels!(column, elements)
|
119
181
|
|
120
182
|
# Add column header
|
121
183
|
column_data << column.headerText
|
122
184
|
|
185
|
+
# Set group labels
|
186
|
+
# either in first column or, if treeColumn is set in the corresponding column
|
187
|
+
# Comparision between the current column and the treeColumn is still a bit vague,
|
188
|
+
# but column == grid.treeColumn is always false, because these are two different objects
|
189
|
+
if (grid.treeColumn == nil && i == 0) ||
|
190
|
+
(grid.treeColumn != nil && column.headerText == grid.treeColumn.headerText)
|
191
|
+
group_labels.length.times do |j|
|
192
|
+
if !group_labels[j].nil?
|
193
|
+
labels[j] = group_labels[j]
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
123
198
|
# Add label data
|
124
199
|
labels.length.times do |j|
|
125
200
|
column_data << labels[j]
|
@@ -133,9 +208,49 @@ module Melomel
|
|
133
208
|
data = data.transpose()
|
134
209
|
|
135
210
|
# Trim whitespace from each cell
|
136
|
-
data.each {|row| row.each {|cell| cell.strip! unless cell.nil?}}
|
211
|
+
data.each {|row| row.each {|cell| cell.strip! unless cell.nil? || !cell.is_a?(String)}}
|
137
212
|
|
138
213
|
return data
|
139
214
|
end
|
215
|
+
|
216
|
+
# Searches for a label in 2D grid data
|
217
|
+
#
|
218
|
+
# label - The label that should be found in the data
|
219
|
+
# data - The data which will be searched in
|
220
|
+
#
|
221
|
+
# Returns an array of all the elements
|
222
|
+
def self.find_index_by_label(data, label)
|
223
|
+
index = nil
|
224
|
+
data.each_index do |i|
|
225
|
+
row = data[i]
|
226
|
+
row.each do |cell|
|
227
|
+
if (cell != nil) && (cell.strip == label)
|
228
|
+
index = i
|
229
|
+
break
|
230
|
+
end
|
231
|
+
end
|
232
|
+
break unless index.nil?
|
233
|
+
end
|
234
|
+
raise "Cannot find '#{value}' on data grid" if index.nil?
|
235
|
+
index
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
# Retrieves all elements of a grid through a cursor
|
240
|
+
#
|
241
|
+
# grid - The grid to retrieve the objects from
|
242
|
+
#
|
243
|
+
# Returns an array of all the elements
|
244
|
+
def self.get_grid_elements(grid)
|
245
|
+
elements = []
|
246
|
+
unless grid.dataProvider.nil?
|
247
|
+
cursor = grid.dataProvider.createCursor()
|
248
|
+
while !cursor.afterLast do
|
249
|
+
elements.push cursor.current
|
250
|
+
break if !cursor.moveNext()
|
251
|
+
end
|
252
|
+
end
|
253
|
+
elements
|
254
|
+
end
|
140
255
|
end
|
141
256
|
end
|
data/lib/melomel/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: melomel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Johnson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-29 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -67,6 +67,17 @@ dependencies:
|
|
67
67
|
version: 0.10.0
|
68
68
|
type: :development
|
69
69
|
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.6.0
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id006
|
70
81
|
description:
|
71
82
|
email:
|
72
83
|
- benbjohnson@yahoo.com
|