razorrisk-razor-control 0.1

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.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/RakeFile +46 -0
  3. data/lib/razor_risk/razor/control/cucumber_helpers/consolidate_reports.rb +80 -0
  4. data/lib/razor_risk/razor/control/cucumber_helpers/executor.rb +108 -0
  5. data/lib/razor_risk/razor/control/cucumber_helpers.rb +3 -0
  6. data/lib/razor_risk/razor/control/diagnostics/util_functions.rb +203 -0
  7. data/lib/razor_risk/razor/control/diagnostics/zeroth_include.rb +27 -0
  8. data/lib/razor_risk/razor/control/exceptions.rb +121 -0
  9. data/lib/razor_risk/razor/control/gem/gem_helpers.rb +397 -0
  10. data/lib/razor_risk/razor/control/rake_helpers/aborter.rb +90 -0
  11. data/lib/razor_risk/razor/control/rake_helpers/diagnostic_tasks.rb +74 -0
  12. data/lib/razor_risk/razor/control/rake_helpers/gem_tasks.rb +128 -0
  13. data/lib/razor_risk/razor/control/rake_helpers/razor_tasks.rb +195 -0
  14. data/lib/razor_risk/razor/control/rake_helpers/task_helpers.rb +86 -0
  15. data/lib/razor_risk/razor/control/rake_helpers.rb +3 -0
  16. data/lib/razor_risk/razor/control/razor/executor.rb +131 -0
  17. data/lib/razor_risk/razor/control/razor/razor_instance.rb +227 -0
  18. data/lib/razor_risk/razor/control/razor.rb +2 -0
  19. data/lib/razor_risk/razor/control/version.rb +41 -0
  20. data/test/unit/control/cucumber_helpers/reports/expected/groups.html +213 -0
  21. data/test/unit/control/cucumber_helpers/reports/expected/no_groups.html +170 -0
  22. data/test/unit/control/cucumber_helpers/reports/groups/LbbwConfig/LbbwConfig.json +69 -0
  23. data/test/unit/control/cucumber_helpers/reports/groups/StandardConfig/StandardConfig.json +69 -0
  24. data/test/unit/control/cucumber_helpers/reports/no_groups/LbbwConfig.json +69 -0
  25. data/test/unit/control/cucumber_helpers/reports/no_groups/StandardConfig/StandardConfig.json +69 -0
  26. data/test/unit/control/cucumber_helpers/tc_consolidate_reports.rb +73 -0
  27. data/test/unit/control/cucumber_helpers/tc_executor.rb +406 -0
  28. data/test/unit/control/gem/tc_gem_helpers.rb +405 -0
  29. data/test/unit/control/rake_helpers/tc_aborter.rb +131 -0
  30. data/test/unit/control/rake_helpers/tc_task_helpers.rb +228 -0
  31. data/test/unit/control/razor/tc_executor.rb +129 -0
  32. data/test/unit/control/razor/tc_razor_instance.rb +517 -0
  33. data/test/unit/control/razor/test_scripts/exit_failure.cmd +3 -0
  34. data/test/unit/control/razor/test_scripts/exit_strange.cmd +3 -0
  35. data/test/unit/control/razor/test_scripts/exit_success.cmd +3 -0
  36. data/test/unit/control/razor/test_scripts/pause.cmd +5 -0
  37. data/test/unit/control/razor/test_scripts/print.cmd +6 -0
  38. data/test/unit/control/tc_exceptions.rb +120 -0
  39. metadata +192 -0
@@ -0,0 +1,73 @@
1
+ # encoding: UTF-8
2
+ #! /usr/bin/env ruby
3
+
4
+ # ######################################################################## #
5
+ #
6
+ # Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
7
+ #
8
+ # ######################################################################## #
9
+
10
+ $:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
11
+
12
+ unless $DEBUG
13
+
14
+ require 'pantheios/globals'
15
+ require 'pantheios/services/null_log_service'
16
+
17
+ ::Pantheios::Globals.INITIAL_SERVICE_CLASSES = [ ::Pantheios::Services::NullLogService ]
18
+ end
19
+
20
+ require 'razor_risk/razor/control/cucumber_helpers/consolidate_reports'
21
+
22
+ require 'xqsr3/extensions/test/unit'
23
+
24
+ require 'tmpdir'
25
+
26
+ require 'test/unit'
27
+
28
+ class Test_CucumbereHelpers < Test::Unit::TestCase
29
+
30
+ include ::RazorRisk::Razor::Control
31
+
32
+ def test_fails_with_invalid_arguments
33
+
34
+ assert_raise_with_message(::ArgumentError, /wrong number of arguments/i) do
35
+ CucumberHelpers.consolidate_reports
36
+ end
37
+ end
38
+
39
+ def test_consolidates_reports_no_groups
40
+
41
+ name = 'report'
42
+ rep_dir = File.join(File.dirname(__FILE__), 'reports', 'no_groups')
43
+
44
+ Dir.mktmpdir do |out_dir|
45
+
46
+ CucumberHelpers.consolidate_reports rep_dir, out_dir, name
47
+
48
+ exp = File.read(File.join(File.dirname(__FILE__), 'reports', 'expected', 'no_groups.html')).split("\n").map!(&:strip)
49
+ act = File.read(File.join(out_dir, 'report.html')).split("\n").map!(&:strip)
50
+ assert_equal exp, act
51
+ end
52
+ end
53
+
54
+ def test_consolidates_reports_with_groups
55
+
56
+ name = 'report'
57
+ rep_dir = File.join(File.dirname(__FILE__), 'reports', 'groups')
58
+
59
+ Dir.mktmpdir do |out_dir|
60
+
61
+ CucumberHelpers.consolidate_reports rep_dir, out_dir, name
62
+
63
+ exp = File.read(File.join(File.dirname(__FILE__), 'reports', 'expected', 'groups.html')).split("\n").map!(&:strip)
64
+ act = File.read(File.join(out_dir, 'report.html')).split("\n").map!(&:strip)
65
+ assert_equal exp, act
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ # ############################## end of file ############################# #
72
+
73
+
@@ -0,0 +1,406 @@
1
+ # encoding: UTF-8
2
+ #! /usr/bin/env ruby
3
+
4
+ # ######################################################################## #
5
+ #
6
+ # Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
7
+ #
8
+ # ######################################################################## #
9
+
10
+ $:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
11
+
12
+ unless $DEBUG
13
+
14
+ require 'pantheios/globals'
15
+ require 'pantheios/services/null_log_service'
16
+
17
+ ::Pantheios::Globals.INITIAL_SERVICE_CLASSES = [ ::Pantheios::Services::NullLogService ]
18
+ end
19
+
20
+ require 'razor_risk/razor/control/cucumber_helpers/executor'
21
+
22
+ require 'xqsr3/extensions/test/unit'
23
+
24
+ require 'test/unit'
25
+
26
+ require 'tmpdir'
27
+
28
+ class Test_CucumbereHelpers < Test::Unit::TestCase
29
+
30
+ include ::RazorRisk::Razor::Control
31
+
32
+ module MockCucumber
33
+
34
+ module Cli
35
+ class Main
36
+ def initialize args
37
+ MockCucumber.last_args(args)
38
+ end
39
+
40
+ def execute!
41
+ MockCucumber.executed(true)
42
+ end
43
+ end
44
+ end
45
+
46
+ def self.executed executed = nil
47
+ @@executed = executed unless executed.nil?
48
+ @@executed
49
+ end
50
+
51
+ def self.last_args args = nil
52
+ @@last_args = args unless args.nil?
53
+ @@last_args
54
+ end
55
+ end
56
+
57
+ def test_base_arguments
58
+
59
+ assert_raise_with_message(::ArgumentError, /must not be empty/) do
60
+ CucumberHelpers.execute(MockCucumber, '')
61
+ end
62
+
63
+ MockCucumber.last_args []
64
+ MockCucumber.executed false
65
+
66
+ name = 'name'
67
+
68
+ CucumberHelpers.execute(
69
+ MockCucumber,
70
+ name
71
+ )
72
+
73
+ assert_true MockCucumber.executed
74
+ assert_equal(
75
+ [ '-s', '-x', '--format', 'progress' ],
76
+ MockCucumber.last_args
77
+ )
78
+ end
79
+
80
+ def test_console_format
81
+
82
+ assert_raise_with_message(
83
+ ::TypeError,
84
+ /must be an instance of string/i
85
+ ) do
86
+ CucumberHelpers.execute(
87
+ MockCucumber,
88
+ 'name',
89
+ console: true
90
+ )
91
+ end
92
+
93
+ MockCucumber.last_args []
94
+ MockCucumber.executed false
95
+
96
+ name = 'name'
97
+ console = 'test_console'
98
+
99
+ CucumberHelpers.execute(
100
+ MockCucumber,
101
+ name,
102
+ console: console,
103
+ )
104
+
105
+ assert_true MockCucumber.executed
106
+ assert_equal(
107
+ [ '-s', '-x', '--format', console],
108
+ MockCucumber.last_args
109
+ )
110
+ end
111
+
112
+ def test_tags
113
+
114
+ assert_raise_with_message(
115
+ ::ArgumentError,
116
+ /must not be empty/i
117
+ ) do
118
+ CucumberHelpers.execute(
119
+ MockCucumber,
120
+ 'name',
121
+ '',
122
+ )
123
+ end
124
+
125
+ MockCucumber.last_args []
126
+ MockCucumber.executed false
127
+
128
+ name = 'name'
129
+ tags = 'some tags'
130
+
131
+ CucumberHelpers.execute(
132
+ MockCucumber,
133
+ name,
134
+ tags,
135
+ )
136
+
137
+ assert_true MockCucumber.executed
138
+ assert_equal(
139
+ [ '-s', '-x', '-t', tags, '--format', 'progress'],
140
+ MockCucumber.last_args
141
+ )
142
+ end
143
+
144
+ def test_report_directory_only_created_if_required
145
+
146
+ MockCucumber.last_args []
147
+ MockCucumber.executed false
148
+
149
+ Dir.mktmpdir do |dir|
150
+
151
+ name = 'name'
152
+ group = 'group'
153
+
154
+ CucumberHelpers.execute(
155
+ MockCucumber,
156
+ name,
157
+ report_directory: dir,
158
+ group: group,
159
+ )
160
+
161
+ out = File.join(dir, group)
162
+
163
+ assert_true MockCucumber.executed
164
+ assert_equal(
165
+ [
166
+ '-s', '-x',
167
+ '--format', 'progress'
168
+ ],
169
+ MockCucumber.last_args
170
+ )
171
+
172
+ assert_path_not_exist out
173
+ end
174
+ end
175
+
176
+ def test_report_directory
177
+
178
+ assert_raise_with_message(
179
+ ::TypeError,
180
+ /must be an instance of string/i
181
+ ) do
182
+ CucumberHelpers.execute(
183
+ MockCucumber,
184
+ 'name',
185
+ report_directory: true,
186
+ )
187
+ end
188
+
189
+ MockCucumber.last_args []
190
+ MockCucumber.executed false
191
+
192
+ Dir.mktmpdir do |dir|
193
+
194
+ name = 'name'
195
+ out_dir = File.join(dir, 'group')
196
+
197
+ CucumberHelpers.execute(
198
+ MockCucumber,
199
+ name,
200
+ report_directory: out_dir,
201
+ html: true,
202
+ )
203
+
204
+ out_file = File.join(out_dir, "#{name}.html")
205
+
206
+ assert_true MockCucumber.executed
207
+ assert_equal(
208
+ [
209
+ '-s', '-x',
210
+ '--format', 'html',
211
+ '-o', out_file,
212
+ '--format', 'progress'
213
+ ],
214
+ MockCucumber.last_args
215
+ )
216
+
217
+ assert_path_exist out_dir
218
+ end
219
+ end
220
+
221
+ def test_group
222
+
223
+ assert_raise_with_message(
224
+ ::TypeError,
225
+ /must be an instance of string/i
226
+ ) do
227
+ CucumberHelpers.execute(
228
+ MockCucumber,
229
+ 'name',
230
+ report_directory: true,
231
+ )
232
+ end
233
+
234
+ MockCucumber.last_args []
235
+ MockCucumber.executed false
236
+
237
+ Dir.mktmpdir do |dir|
238
+
239
+ name = 'name'
240
+ group = 'group'
241
+
242
+ CucumberHelpers.execute(
243
+ MockCucumber,
244
+ name,
245
+ report_directory: dir,
246
+ group: group,
247
+ html: true,
248
+ )
249
+
250
+ out_dir = File.join(dir, group)
251
+ out_file = File.join(out_dir, "#{name}.html")
252
+
253
+ assert_true MockCucumber.executed
254
+ assert_equal(
255
+ [
256
+ '-s', '-x',
257
+ '--format', 'html',
258
+ '-o', out_file,
259
+ '--format', 'progress'
260
+ ],
261
+ MockCucumber.last_args
262
+ )
263
+
264
+ assert_path_exist out_dir
265
+ end
266
+ end
267
+
268
+ def test_html
269
+
270
+ assert_raise_with_message(
271
+ ::TypeError,
272
+ /must be an instance of TrueClass or FalseClass/i
273
+ ) do
274
+ CucumberHelpers.execute(
275
+ MockCucumber,
276
+ 'name',
277
+ html: 'abc',
278
+ )
279
+ end
280
+
281
+ MockCucumber.last_args []
282
+ MockCucumber.executed false
283
+
284
+ Dir.mktmpdir do |dir|
285
+
286
+ name = 'name'
287
+ out_dir = File.join(dir, 'group')
288
+
289
+ CucumberHelpers.execute(
290
+ MockCucumber,
291
+ name,
292
+ report_directory: out_dir,
293
+ html: true,
294
+ )
295
+
296
+ out_file = File.join(out_dir, "#{name}.html")
297
+
298
+ assert_true MockCucumber.executed
299
+ assert_equal(
300
+ [
301
+ '-s', '-x',
302
+ '--format', 'html',
303
+ '-o', out_file,
304
+ '--format', 'progress'
305
+ ],
306
+ MockCucumber.last_args
307
+ )
308
+
309
+ assert_path_exist out_dir
310
+ end
311
+ end
312
+
313
+ def test_json
314
+
315
+ assert_raise_with_message(
316
+ ::TypeError,
317
+ /must be an instance of TrueClass or FalseClass/i
318
+ ) do
319
+ CucumberHelpers.execute(
320
+ MockCucumber,
321
+ 'name',
322
+ json: 'abc',
323
+ )
324
+ end
325
+
326
+ MockCucumber.last_args []
327
+ MockCucumber.executed false
328
+
329
+ Dir.mktmpdir do |dir|
330
+
331
+ name = 'name'
332
+ out_dir = File.join(dir, 'group')
333
+
334
+ CucumberHelpers.execute(
335
+ MockCucumber,
336
+ name,
337
+ report_directory: out_dir,
338
+ json: true,
339
+ )
340
+
341
+ out_file = File.join(out_dir, "#{name}.json")
342
+
343
+ assert_true MockCucumber.executed
344
+ assert_equal(
345
+ [
346
+ '-s', '-x',
347
+ '--format', 'json',
348
+ '-o', out_file,
349
+ '--format', 'progress'
350
+ ],
351
+ MockCucumber.last_args
352
+ )
353
+
354
+ assert_path_exist out_dir
355
+ end
356
+ end
357
+
358
+ def test_junit
359
+
360
+ assert_raise_with_message(
361
+ ::TypeError,
362
+ /must be an instance of TrueClass or FalseClass/i
363
+ ) do
364
+ CucumberHelpers.execute(
365
+ MockCucumber,
366
+ 'name',
367
+ junit: 'abc',
368
+ )
369
+ end
370
+
371
+ MockCucumber.last_args []
372
+ MockCucumber.executed false
373
+
374
+ Dir.mktmpdir do |dir|
375
+
376
+ name = 'name'
377
+ out_dir = File.join(dir, 'group')
378
+
379
+ CucumberHelpers.execute(
380
+ MockCucumber,
381
+ name,
382
+ report_directory: out_dir,
383
+ junit: true,
384
+ )
385
+
386
+ out_path = File.join(out_dir, 'JUnit')
387
+
388
+ assert_true MockCucumber.executed
389
+ assert_equal(
390
+ [
391
+ '-s', '-x',
392
+ '--format', 'junit',
393
+ '-o', out_path,
394
+ '--format', 'progress'
395
+ ],
396
+ MockCucumber.last_args
397
+ )
398
+
399
+ assert_path_exist out_dir
400
+ end
401
+ end
402
+ end
403
+
404
+ # ############################## end of file ############################# #
405
+
406
+