testcentricity_web 4.4.7 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df25b2f03c601530a6cac7652a619802fdbcf541cfac60a372abd80cd88539dc
4
- data.tar.gz: 06e5852b86f220a53716c5acda9e2621e9a0e673bb88c1b6808ebd1f9c2b6310
3
+ metadata.gz: c027bd7d2686918567b724b00a6414e4baedc58812e3177d870b646e24885f74
4
+ data.tar.gz: 79dd0592a8e0bb3c51a142214f9e0cef4b4a3712a90d12ec1f14224391404fcb
5
5
  SHA512:
6
- metadata.gz: 0107a6c5d7a1bfe3ab8dd3d17c394e5ac2630ef7f53a2947c2916296c3281875d7c25b163a2270088f77e193878e7b128843518c39aa110e32b8c8b44b63c856
7
- data.tar.gz: 50cebc5c0b3b0e5f07cf05a9d594916abd6c6edc3ccc3fc9025bae3c60c2793d3639b91770a48d54206ba6f3fc91c2b27a8d1a5ddbbc6da0a0898fa8661572f0
6
+ metadata.gz: f086bf05254d5cebe9461ddddcbbeae1d1a72e4b1a4ff9db2a17df1c728c3d0217459a604bafc1a7e60975857a206339310c6849aa6bb5380dc949682ec485b4
7
+ data.tar.gz: e4e037bf027de684205a7f34a5591b422043d63c6f4f521d4f52ca3a9094edd30b38163ddabe55b5273bda5b51896e79290762286e72cab762d6f256ab842da8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
4
 
5
+ ## [4.5.0] - 16-JAN-2024
6
+
7
+ ### Removed
8
+ * Support for test data assets stored in Excel `.xls` has been removed because `.xls` files cannot be properly tracked
9
+ and diffed by source control tools like git.
10
+ * `ExcelData` and `ExcelDataSource` classes removed.
11
+ * Removed dependence on `spreadsheet` gem.
12
+
13
+
5
14
  ## [4.4.7] - 13-JAN-2024
6
15
 
7
16
  ### Fixed
@@ -10,7 +10,6 @@ module TestCentricity
10
10
 
11
11
  PRIMARY_DATA_PATH ||= 'config/test_data/'
12
12
  PRIMARY_DATA_FILE ||= "#{PRIMARY_DATA_PATH}data."
13
- XL_PRIMARY_DATA_FILE ||= "#{PRIMARY_DATA_FILE}xls"
14
13
  YML_PRIMARY_DATA_FILE ||= "#{PRIMARY_DATA_FILE}yml"
15
14
  JSON_PRIMARY_DATA_FILE ||= "#{PRIMARY_DATA_FILE}json"
16
15
 
@@ -51,37 +50,6 @@ module TestCentricity
51
50
  def self.current=(current)
52
51
  @current = current
53
52
  end
54
-
55
- # :nocov:
56
- def to_hash(node_name = nil)
57
- data = {}
58
- if node_name.nil?
59
- data = { class: self.class.name, attributes: self.attributes }
60
- else
61
- data[node_name] = { class: self.class.name, attributes: self.attributes }
62
- end
63
- data
64
- end
65
-
66
- def to_yaml(node_name = nil)
67
- data = to_hash(node_name)
68
- data.to_yaml
69
- end
70
-
71
- def write_yaml_data(file_name, mode, node_name = nil)
72
- File.open(file_name, mode) { |file| file.write(to_yaml(node_name)) }
73
- end
74
-
75
- def to_json(node_name = nil)
76
- data = to_hash(node_name)
77
- data.to_json
78
- end
79
-
80
- def write_json_data(file_name, mode, node_name = nil)
81
- File.open(file_name, mode) { |file| file.write(to_json(node_name)) }
82
- end
83
-
84
- # :nocov:
85
53
  end
86
54
 
87
55
 
@@ -97,12 +65,6 @@ module TestCentricity
97
65
  data[node_name]
98
66
  end
99
67
 
100
- def write_yaml_node_data(file_name, node_name, node_data)
101
- data = read_yaml_node_data(file_name, node_name)
102
- data[node_name] = node_data
103
- File.write(@file_path, data.to_yaml)
104
- end
105
-
106
68
  def read_json_node_data(file_name, node_name)
107
69
  @file_path = "#{PRIMARY_DATA_PATH}#{file_name}"
108
70
  @node = node_name
@@ -111,12 +73,6 @@ module TestCentricity
111
73
  data[node_name]
112
74
  end
113
75
 
114
- def write_json_node_data(file_name, node_name, node_data)
115
- data = read_json_node_data(file_name, node_name)
116
- data[node_name] = node_data
117
- File.write(@file_path, data.to_json)
118
- end
119
-
120
76
  private
121
77
 
122
78
  def self.calculate_dynamic_value(value)
@@ -138,48 +94,6 @@ module TestCentricity
138
94
  end
139
95
  result.to_s
140
96
  end
141
- end
142
- # :nocov:
143
-
144
-
145
- class ExcelDataSource < TestCentricity::DataSource
146
- attr_accessor :worksheet
147
- attr_accessor :row_spec
148
-
149
- def pick_excel_data_source(sheet, row_spec)
150
- @worksheet = sheet
151
- if ENV['TEST_ENVIRONMENT']
152
- environment = ENV['TEST_ENVIRONMENT']
153
- data_file = "#{PRIMARY_DATA_PATH}#{environment}_data.xls"
154
- data_file = XL_PRIMARY_DATA_FILE unless ExcelData.row_spec_exists?(data_file, @worksheet, row_spec)
155
- else
156
- data_file = XL_PRIMARY_DATA_FILE
157
- end
158
- @file_path = data_file
159
- data_file
160
- end
161
-
162
- def read_excel_row_data(sheet, row_name, parallel = false)
163
- @row_spec = parallel == :parallel && ENV['PARALLEL'] ? "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_name
164
- ExcelData.read_row_data(pick_excel_data_source(sheet, @row_spec), sheet, @row_spec)
165
- end
166
-
167
- # :nocov:
168
- def read_excel_pool_data(sheet, row_name, parallel = false)
169
- @row_spec = parallel == :parallel && ENV['PARALLEL'] ? "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_name
170
- ExcelData.read_row_from_pool(pick_excel_data_source(sheet, row_name), sheet, @row_spec)
171
- end
172
-
173
- def read_excel_range_data(sheet, range_name)
174
- @row_spec = range_name
175
- ExcelData.read_range_data(pick_excel_data_source(sheet, range_name), sheet, range_name)
176
- end
177
-
178
- def write_excel_row_data(sheet, row_name, row_data, parallel = false)
179
- @row_spec = parallel == :parallel && ENV['PARALLEL'] ? "#{row_name}#{ENV['TEST_ENV_NUMBER']}" : row_name
180
- ExcelData.write_row_data(pick_excel_data_source(sheet, @row_spec), sheet, @row_spec, row_data)
181
- end
182
97
  # :nocov:
183
98
  end
184
99
  end
185
-
@@ -1,15 +1,13 @@
1
1
  module TestCentricity
2
- class EnvironData < TestCentricity::ExcelDataSource
2
+ class EnvironData < TestCentricity::DataSource
3
3
  attr_accessor :current
4
4
  attr_accessor :generic_data
5
5
  attr_accessor :environ_specific_data
6
6
 
7
- def self.find_environ(environ_name, source_type = :excel)
7
+ def self.find_environ(environ_name, source_type = :yaml)
8
8
  raise 'No environment specified' if environ_name.nil?
9
9
 
10
10
  data = case source_type
11
- when :excel
12
- ExcelData.read_row_data(XL_PRIMARY_DATA_FILE, 'Environments', environ_name)
13
11
  when :yaml
14
12
  # read generic test data from data.yml file
15
13
  @generic_data ||= YAML.load_file(YML_PRIMARY_DATA_FILE)
@@ -36,6 +34,8 @@ module TestCentricity
36
34
  end
37
35
 
38
36
  read('Environments', environ_name)
37
+ else
38
+ raise "#{source_type} is not a supported data source type"
39
39
  end
40
40
  @current = Environ.new(data)
41
41
  Environ.current = @current
@@ -379,7 +379,7 @@ module TestCentricity
379
379
  end
380
380
 
381
381
  def self.driver_name=(name)
382
- name = name.downcase.to_sym if name.is_a?(String)
382
+ name = name.gsub(/\s+/, '_').downcase.to_sym if name.is_a?(String)
383
383
  @driver_name = name
384
384
  end
385
385
 
@@ -480,8 +480,8 @@ module TestCentricity
480
480
  end
481
481
 
482
482
  def self.report_header
483
- report_header = "\n<b><u>TEST ENVIRONMENT</u>:</b> #{ENV['TEST_ENVIRONMENT']}\n"\
484
- " <b>Browser:</b>\t #{@browser.capitalize}\n"
483
+ report_header = "\n<b><u>TEST ENVIRONMENT</u>:</b> #{ENV['TEST_ENVIRONMENT']}\n"
484
+ report_header = "#{report_header} <b>Browser:</b>\t #{@browser.capitalize}\n" if @browser
485
485
  report_header = "#{report_header} <b>Device:</b>\t #{@device_name}\n" if @device_name
486
486
  report_header = "#{report_header} <b>Device OS:</b>\t #{@device_os} #{@device_os_version}\n" if @device_os
487
487
  report_header = "#{report_header} <b>Device type:</b>\t #{@device_type}\n" if @device_type
@@ -1,3 +1,3 @@
1
1
  module TestCentricityWeb
2
- VERSION = '4.4.7'
2
+ VERSION = '4.5.0'
3
3
  end
@@ -65,7 +65,7 @@ module TestCentricity
65
65
  context = case Environ.driver
66
66
  when :appium
67
67
  initialize_appium
68
- 'Appium'
68
+ "#{Environ.device_os} #{Environ.device_type} #{Environ.device} on Appium"
69
69
  when :webdriver
70
70
  initialize_local_browser
71
71
  'local browser instance'
@@ -16,7 +16,6 @@ require 'testcentricity_web/web_core/webdriver_helper'
16
16
 
17
17
  require 'testcentricity_web/data_objects/data_objects_helper'
18
18
  require 'testcentricity_web/data_objects/environment'
19
- require 'testcentricity_web/data_objects/excel_helper'
20
19
 
21
20
  require 'testcentricity_web/web_elements/ui_element'
22
21
  require 'testcentricity_web/web_elements/button'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.7
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -276,20 +276,6 @@ dependencies:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
278
  version: 4.14.0
279
- - !ruby/object:Gem::Dependency
280
- name: spreadsheet
281
- requirement: !ruby/object:Gem::Requirement
282
- requirements:
283
- - - '='
284
- - !ruby/object:Gem::Version
285
- version: 1.1.7
286
- type: :runtime
287
- prerelease: false
288
- version_requirements: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - '='
291
- - !ruby/object:Gem::Version
292
- version: 1.1.7
293
279
  - !ruby/object:Gem::Dependency
294
280
  name: test-unit
295
281
  requirement: !ruby/object:Gem::Requirement
@@ -343,7 +329,6 @@ files:
343
329
  - lib/testcentricity_web/browser_helper.rb
344
330
  - lib/testcentricity_web/data_objects/data_objects_helper.rb
345
331
  - lib/testcentricity_web/data_objects/environment.rb
346
- - lib/testcentricity_web/data_objects/excel_helper.rb
347
332
  - lib/testcentricity_web/exception_queue_helper.rb
348
333
  - lib/testcentricity_web/utility_helpers.rb
349
334
  - lib/testcentricity_web/version.rb
@@ -1,276 +0,0 @@
1
- require 'spreadsheet'
2
-
3
-
4
- module TestCentricity
5
- class ExcelData
6
- @mru = {}
7
-
8
- def self.worksheet_exists?(file, sheet)
9
- exists = false
10
- if File.exist?(file)
11
- work_book = Spreadsheet.open(file)
12
- worksheets = work_book.worksheets
13
- worksheets.each do |worksheet|
14
- if worksheet.name == sheet
15
- exists = true
16
- break
17
- end
18
- end
19
- end
20
- exists
21
- end
22
-
23
- def self.row_spec_exists?(file, sheet, row_spec)
24
- exists = false
25
- if worksheet_exists?(file, sheet)
26
- work_book = Spreadsheet.open(file)
27
- work_sheet = work_book.worksheet(sheet)
28
- # get column headings from row 0 of worksheet
29
- headings = work_sheet.row(0)
30
- # if row_spec is a string then we have to find a matching row name
31
- if row_spec.is_a? String
32
- column_number = 0
33
- exists = false
34
- headings.each do |heading|
35
- if heading == 'ROW_NAME'
36
- exists = true
37
- break
38
- end
39
- column_number += 1
40
- end
41
- raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless exists
42
- # find first cell in ROW_NAME column containing a string that matches the row_spec parameter
43
- exists = false
44
- work_sheet.each do |row|
45
- if row[column_number] == row_spec
46
- exists = true
47
- break
48
- end
49
- end
50
- end
51
- end
52
- exists
53
- end
54
-
55
- def self.read_row_data(file, sheet, row_spec, columns = nil)
56
- raise "File #{file} does not exists" unless File.exist?(file)
57
- work_book = Spreadsheet.open(file)
58
- work_sheet = work_book.worksheet(sheet)
59
- # get column headings from row 0 of worksheet
60
- headings = work_sheet.row(0)
61
- # if row_spec is a string then we have to find a matching row name
62
- if row_spec.is_a? String
63
- column_number = 0
64
- found = false
65
- headings.each do |heading|
66
- if heading == 'ROW_NAME'
67
- found = true
68
- break
69
- end
70
- column_number += 1
71
- end
72
- raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
73
- # find first cell in ROW_NAME column containing a string that matches the row_spec parameter
74
- found = false
75
- row_number = 0
76
- work_sheet.each do |row|
77
- if row[column_number] == row_spec
78
- found = true
79
- break
80
- end
81
- row_number += 1
82
- end
83
- raise "Could not find a row named '#{row_spec}' in worksheet #{sheet}" unless found
84
- data = work_sheet.row(row_number)
85
- # if row_spec is a number then ensure that it doesn't exceed the number of available rows
86
- elsif row_spec.is_a? Numeric
87
- raise "Row # #{row_spec} is greater than number of rows in worksheet #{sheet}" if row_spec > work_sheet.last_row_index
88
- data = work_sheet.row(row_spec)
89
- end
90
-
91
- # if no columns have been specified, return all columns
92
- columns = headings if columns.nil?
93
- # create results hash table
94
- result = Hash.new
95
- columns.each do |column|
96
- column_number = 0
97
- found = false
98
- headings.each do |heading|
99
- if column == heading
100
- value = data[column_number].to_s
101
- value = calculate_dynamic_value(value) if value.start_with? 'eval!'
102
- result[column] = value
103
- found = true
104
- break
105
- end
106
- column_number += 1
107
- end
108
- raise "Could not find a column named '#{column}' in worksheet #{sheet}" unless found
109
- end
110
- result
111
- end
112
-
113
- # :nocov:
114
- def self.read_row_from_pool(file, sheet, row_spec, columns = nil)
115
- raise "File #{file} does not exists" unless File.exist?(file)
116
- work_book = Spreadsheet.open(file)
117
- work_sheet = work_book.worksheet(sheet)
118
-
119
- pool_spec_key = "#{sheet}:#{row_spec}"
120
- if @mru.key?(pool_spec_key)
121
- pool_spec = @mru[pool_spec_key]
122
- row_start = pool_spec[:start_row]
123
- row_end = pool_spec[:num_rows]
124
- pool_rows = (row_start..row_start + row_end - 1).to_a
125
- mru_rows = pool_spec[:used_rows]
126
- new_row = pool_rows.sample.to_i
127
- if mru_rows.size == pool_spec[:num_rows]
128
- mru_rows = [new_row]
129
- else
130
- while mru_rows.include?(new_row)
131
- new_row = pool_rows.sample.to_i
132
- end
133
- mru_rows.push(new_row)
134
- mru_rows.sort!
135
- end
136
-
137
- pool_spec = {
138
- start_row: row_start,
139
- num_rows: row_end,
140
- used_rows: mru_rows
141
- }
142
- else
143
- # get column headings from row 0 of worksheet
144
- headings = work_sheet.row(0)
145
- column_number = 0
146
- found = false
147
- headings.each do |heading|
148
- if heading == 'ROW_NAME'
149
- found = true
150
- break
151
- end
152
- column_number += 1
153
- end
154
- raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
155
- # find cell(s) in ROW_NAME column containing a string that matches the row_spec parameter
156
- found = []
157
- row_number = 0
158
- work_sheet.each do |row|
159
- if row[column_number] == row_spec
160
- found.push(row_number)
161
- elsif !found.empty?
162
- break
163
- end
164
- row_number += 1
165
- end
166
- raise "Could not find a row named '#{row_spec}' in worksheet #{sheet}" if found.empty?
167
-
168
- new_row = found.sample.to_i
169
- pool_spec = {
170
- start_row: found[0],
171
- num_rows: found.size,
172
- used_rows: [new_row]
173
- }
174
- end
175
- @mru[pool_spec_key] = pool_spec
176
-
177
- read_row_data(file, sheet, new_row, columns)
178
- end
179
-
180
- def self.read_range_data(file, sheet, range_spec)
181
- raise "File #{file} does not exists" unless File.exist?(file)
182
- work_book = Spreadsheet.open(file)
183
- work_sheet = work_book.worksheet(sheet)
184
- # get column headings from row 0 of worksheet
185
- headings = work_sheet.row(0)
186
- column_number = 0
187
- found = false
188
- headings.each do |heading|
189
- if heading == 'ROW_NAME'
190
- found = true
191
- break
192
- end
193
- column_number += 1
194
- end
195
- raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
196
- # find cell(s) in ROW_NAME column containing a string that matches the range_spec parameter
197
- found = []
198
- row_number = 0
199
- work_sheet.each do |row|
200
- if row[column_number] == range_spec
201
- found.push(row_number)
202
- elsif !found.empty?
203
- break
204
- end
205
- row_number += 1
206
- end
207
- raise "Could not find a row named '#{range_spec}' in worksheet #{sheet}" if found.empty?
208
-
209
- result = []
210
- found.each do |row|
211
- result.push(read_row_data(file, sheet, row))
212
- end
213
- result
214
- end
215
-
216
- def self.write_row_data(file, sheet, row_spec, row_data)
217
- raise "File #{file} does not exists" unless File.exist?(file)
218
- work_book = Spreadsheet.open(file)
219
- work_sheet = work_book.worksheet(sheet)
220
- # get column headings from row 0 of worksheet
221
- headings = work_sheet.row(0)
222
- # find a matching row name
223
- column_number = 0
224
- found = false
225
- headings.each do |heading|
226
- if heading == 'ROW_NAME'
227
- found = true
228
- break
229
- end
230
- column_number += 1
231
- end
232
- raise "Could not find a column named ROW_NAME in worksheet #{sheet}" unless found
233
- # find first cell in ROW_NAME column containing a string that matches the row_spec parameter
234
- found = false
235
- row_number = 0
236
- work_sheet.each do |row|
237
- if row[column_number] == row_spec
238
- found = true
239
- break
240
- end
241
- row_number += 1
242
- end
243
- raise "Could not find a row named '#{row_spec}' in worksheet #{sheet}" unless found
244
- # iterate through the row_data Hash
245
- row_data.each do |column, value|
246
- column_number = 0
247
- found = false
248
- # find the column heading that matches the specified column name
249
- headings.each do |heading|
250
- if heading == column
251
- found = true
252
- break
253
- end
254
- column_number += 1
255
- end
256
- raise "Could not find a column named '#{column}' in worksheet #{sheet}" unless found
257
- # set the value of the specified row and column
258
- work_sheet.rows[row_number][column_number] = value
259
- end
260
- # iterate through all worksheets so that all worksheets are saved in new Excel document
261
- worksheets = work_book.worksheets
262
- worksheets.each do |worksheet|
263
- headings = worksheet.row(0)
264
- worksheet.rows[0][0] = headings[0]
265
- end
266
- # write all changes to new Excel document
267
- outfile = file.gsub(File.basename(file), 'output.xls')
268
- work_book.write outfile
269
- # delete original Excel document
270
- File.delete(file)
271
- # rename new Excel document, replacing the original
272
- File.rename(outfile, file)
273
- end
274
- # :nocov:
275
- end
276
- end