spectre-core 1.12.4 → 1.14.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d2cb2622682713c0fc37e7c0e679aa0d93f01ac9af389c8430496a272608038
4
- data.tar.gz: 8b313cd7952c0b9e4baf9e8f0cec0af397d1f8cf8fc25760204714f687718df8
3
+ metadata.gz: 3ec3e298c4efb325f628370a3855a110136cba4a9d7f870db90d95a5b39c9e8a
4
+ data.tar.gz: fde6391319206d2f8d603b02be31f0f5bb72d424fcb25541b9be0597670ce49a
5
5
  SHA512:
6
- metadata.gz: c3e939b9e9851ece96d27e31d19fa7f4c5b26bd9141e28e2e5964b5f20ed1f9c9b0f4a77800b87c411d1c271d0b4acf1afa1f50359e832842e241a1ba536b811
7
- data.tar.gz: d105a5a9924cba80b028790a538945087ef0e19a30763e619b712c1d7b31b54259a03504a5a52d1f1cc24be6a03f1e8185d499ed9e7343a17655c4336f22dd40
6
+ metadata.gz: 5fdb065d1ce08d8c4e78e164bc1caad26ed03d50f4cf6199398699859cb9a81a00260b6e3af785de4a7852aa45da1ae61a2977b0b92bbb5c0c832e6079178cce
7
+ data.tar.gz: ce6b95998d3e3145876bc1d7bb8fe06ce941f1327a6a283557e9944447ffba888c3012124c474d0321f5e9eb91914b53fbdd285255f947db34dd783e084446b5
data/exe/spectre CHANGED
@@ -16,6 +16,7 @@ end
16
16
 
17
17
 
18
18
  DEFAULT_CONFIG = {
19
+ 'project' => nil,
19
20
  'config_file' => './spectre.yml',
20
21
  'environment' => 'default',
21
22
  'specs' => [],
@@ -26,8 +27,8 @@ DEFAULT_CONFIG = {
26
27
  'Spectre::Reporter::Console',
27
28
  ],
28
29
  'loggers' => [
29
- 'Spectre::Logger::Console',
30
- 'Spectre::Logger::File',
30
+ 'Spectre::Logging::Console',
31
+ 'Spectre::Logging::File',
31
32
  ],
32
33
  'log_file' => './logs/spectre_<date>.log',
33
34
  'log_format' => {
@@ -54,7 +55,6 @@ DEFAULT_CONFIG = {
54
55
  'modules' => [
55
56
  'spectre/helpers',
56
57
  'spectre/reporter/console',
57
- 'spectre/reporter/junit',
58
58
  'spectre/logger/console',
59
59
  'spectre/logger/file',
60
60
  'spectre/assertion',
@@ -66,6 +66,7 @@ DEFAULT_CONFIG = {
66
66
  'spectre/http/basic_auth',
67
67
  'spectre/http/keystone',
68
68
  'spectre/resources',
69
+ 'spectre/async',
69
70
  ],
70
71
  'include' => [
71
72
 
@@ -79,20 +80,24 @@ DEFAULT_CONFIG = {
79
80
  cmd_options = {}
80
81
  property_overrides = {}
81
82
 
82
- opt_parser = OptionParser.new do |opts|
83
- opts.banner = %{Spectre #{Spectre::VERSION}
83
+ $COMMAND = ['spectre'].concat(ARGV.clone).join(' ')
84
84
 
85
- Usage: spectre [command] [options]
85
+ OptionParser.new do |opts|
86
+ opts.banner = <<~BANNER
87
+ Spectre #{Spectre::VERSION}
86
88
 
87
- Commands:
88
- list List specs
89
- run Run specs (default)
90
- show Print current environment settings
91
- dump Dumps the given environment in YAML format to console
92
- cleanup Will remove all generated files (e.g. logs and reports)
93
- init Initializes a new spectre project
89
+ Usage: spectre [command] [options]
94
90
 
95
- Specific options:}
91
+ Commands:
92
+ list List specs
93
+ run Run specs (default)
94
+ show Print current environment settings
95
+ dump Dumps the given environment in YAML format to console
96
+ cleanup Will remove all generated files (e.g. logs and reports)
97
+ init Initializes a new spectre project
98
+
99
+ Specific options:
100
+ BANNER
96
101
 
97
102
  opts.on('-s SPEC,SPEC', '--specs SPEC,SPEC', Array, 'The specs to run') do |specs|
98
103
  cmd_options['specs'] = specs
@@ -130,11 +135,17 @@ Specific options:}
130
135
  cmd_options['out_path'] = File.absolute_path(path)
131
136
  end
132
137
 
133
- opts.on('-r NAME', '--reporters NAME', Array, "A list of reporters to use") do |reporters|
138
+ opts.on('-r NAME,NAME', '--reporters NAME,NAME', Array, "A list of reporters to use") do |reporters|
134
139
  cmd_options['reporters'] = reporters
135
140
  end
136
141
 
137
- opts.on('-d', '--debug', "Run in debug mode") do
142
+ opts.on('-m MODULE,MODULE', '--modules MODULE,MODULE', Array, "Load the given modules") do |modules|
143
+ modules.each do |mod|
144
+ require mod
145
+ end
146
+ end
147
+
148
+ opts.on('-d', '--debug', "Run in debug mode. Do not use in production!") do
138
149
  cmd_options['debug'] = true
139
150
  end
140
151
 
@@ -159,9 +170,9 @@ Specific options:}
159
170
  end
160
171
  end
161
172
 
162
- opts.separator "\nCommon options:"
173
+ opts.separator "\n Common options:"
163
174
 
164
- opts.on_tail('--version', 'Print current installed version') do
175
+ opts.on_tail('-v', '--version', 'Print current installed version') do
165
176
  puts Spectre::VERSION
166
177
  exit
167
178
  end
@@ -199,13 +210,19 @@ if File.exists? config_file
199
210
  Dir.chdir File.dirname(config_file)
200
211
  end
201
212
 
213
+ # Set config options, which are only allowed to be overriden by command options
214
+ cfg['debug'] = DEFAULT_CONFIG['debug']
215
+
216
+ # Set project name
217
+ cfg['project'] = File.basename(Dir.pwd) unless cfg['project']
218
+
202
219
  cfg.deep_merge! cmd_options
203
220
 
221
+
204
222
  ###########################################
205
223
  # Load Environment
206
224
  ###########################################
207
225
 
208
-
209
226
  envs = {}
210
227
  read_env_files = {}
211
228
  cfg['env_patterns'].each do |pattern|
@@ -250,128 +267,131 @@ require_relative '../lib/spectre/environment' unless cfg['exclude'].include? 'sp
250
267
  Spectre.configure(cfg)
251
268
 
252
269
 
253
- ###########################################
254
- # Load Specs
255
- ###########################################
270
+ # Load specs only, when listing or running specs
271
+ if ['list', 'run'].include? action
256
272
 
273
+ ###########################################
274
+ # Load Specs
275
+ ###########################################
257
276
 
258
- cfg['spec_patterns'].each do |pattern|
259
- Dir.glob(pattern).each do|f|
260
- require_relative File.join(Dir.pwd, f)
277
+
278
+ cfg['spec_patterns'].each do |pattern|
279
+ Dir.glob(pattern).each do|f|
280
+ require_relative File.join(Dir.pwd, f)
281
+ end
261
282
  end
262
- end
263
283
 
264
284
 
265
- ###########################################
266
- # List specs
267
- ###########################################
285
+ ###########################################
286
+ # List specs
287
+ ###########################################
268
288
 
269
289
 
270
- if 'list' == action
271
- colors = [:blue, :magenta, :yellow, :green]
272
- specs = Spectre.specs(cfg['specs'], cfg['tags'])
290
+ if 'list' == action
291
+ colors = [:blue, :magenta, :yellow, :green]
292
+ specs = Spectre.specs(cfg['specs'], cfg['tags'])
273
293
 
274
- exit 1 unless specs.any?
294
+ exit 1 unless specs.any?
275
295
 
276
- counter = 0
296
+ counter = 0
297
+
298
+ specs.group_by { |x| x.subject }.each do |subject, spec_group|
299
+ spec_group.each do |spec|
300
+ tags = spec.tags.map { |x| '#' + x.to_s }.join ' '
301
+ desc = subject.desc
302
+ desc += ' - ' + spec.context.__desc + ' -' if spec.context.__desc
303
+ desc += ' ' + spec.desc
304
+ puts "[#{spec.name}]".send(colors[counter % colors.length]) + " #{desc} #{tags.cyan}"
305
+ end
277
306
 
278
- specs.group_by { |x| x.subject }.each do |subject, spec_group|
279
- spec_group.each do |spec|
280
- tags = spec.tags.map { |x| '#' + x.to_s }.join ' '
281
- desc = subject.desc
282
- desc += ' - ' + spec.context.__desc + ' -' if spec.context.__desc
283
- desc += ' ' + spec.desc
284
- puts "[#{spec.name}]".send(colors[counter % colors.length]) + " #{desc} #{tags.cyan}"
307
+ counter += 1
285
308
  end
286
309
 
287
- counter += 1
310
+ exit 0
288
311
  end
289
312
 
290
- exit 0
291
- end
292
-
293
313
 
294
- ###########################################
295
- # Run
296
- ###########################################
314
+ ###########################################
315
+ # Run
316
+ ###########################################
297
317
 
298
318
 
299
- if 'run' == action
300
- # Initialize logger
301
- now = Time.now
319
+ if 'run' == action
320
+ # Initialize logger
321
+ now = Time.now
302
322
 
303
- cfg['log_file'] = cfg['log_file'].frmt(
304
- {
305
- shortdate: now.strftime('%Y-%m-%d'),
306
- date: now.strftime('%Y-%m-%d_%H%M%S'),
307
- timestamp: now.strftime('%s'),
308
- subject: 'spectre',
309
- })
323
+ cfg['log_file'] = cfg['log_file'].frmt({
324
+ shortdate: now.strftime('%Y-%m-%d'),
325
+ date: now.strftime('%Y-%m-%d_%H%M%S'),
326
+ timestamp: now.strftime('%s'),
327
+ subject: 'spectre',
328
+ })
310
329
 
311
- log_dir = File.dirname cfg['log_file']
312
- FileUtils.makedirs log_dir unless Dir.exists? log_dir
330
+ log_dir = File.dirname(cfg['log_file'])
331
+ FileUtils.makedirs(log_dir)
313
332
 
314
- # Load Modules
333
+ # Load Modules
315
334
 
316
- cfg['modules']
317
- .concat(cfg['include'])
318
- .select { |mod| !cfg['exclude'].include? mod }
319
- .each do |mod|
320
- begin
321
- mod_file = mod + '.rb'
322
- spectre_lib_mod = File.join(File.dirname(__dir__), 'lib', mod_file)
335
+ cfg['modules']
336
+ .concat(cfg['include'])
337
+ .select { |mod| !cfg['exclude'].include? mod }
338
+ .each do |mod|
339
+ begin
340
+ mod_file = mod + '.rb'
341
+ spectre_lib_mod = File.join(File.dirname(__dir__), 'lib', mod_file)
323
342
 
324
- if File.exists? mod_file
325
- require_relative mod_file
343
+ if File.exists? mod_file
344
+ require_relative mod_file
326
345
 
327
- elsif File.exists? spectre_lib_mod
328
- require_relative spectre_lib_mod
346
+ elsif File.exists? spectre_lib_mod
347
+ require_relative spectre_lib_mod
329
348
 
330
- else
331
- require mod
349
+ else
350
+ require mod
351
+ end
352
+ rescue LoadError => e
353
+ puts "Unable to load module #{mod}. Check if the module exists or remove it from your spectre config:\n#{e.message}"
354
+ exit 1
332
355
  end
333
- rescue LoadError => e
334
- puts "Unable to load module #{mod}. Check if the module exists or remove it from your spectre config:\n#{e.message}"
335
- exit 1
336
356
  end
337
- end
338
357
 
339
- # Load mixins
358
+ # Load mixins
340
359
 
341
- cfg['mixin_patterns'].each do |pattern|
342
- Dir.glob(pattern).each do|f|
343
- require_relative File.join(Dir.pwd, f)
360
+ cfg['mixin_patterns'].each do |pattern|
361
+ Dir.glob(pattern).each do|f|
362
+ require_relative File.join(Dir.pwd, f)
363
+ end
344
364
  end
345
- end
346
365
 
347
- Spectre.configure(cfg)
366
+ Spectre.configure(cfg)
348
367
 
349
- Spectre::Logger.debug! if cfg['debug']
368
+ Spectre::Logging.debug! if cfg['debug']
350
369
 
351
- cfg['loggers'].each do |logger_name|
352
- logger = Kernel.const_get(logger_name).new(cfg)
353
- Spectre::Logger.add(logger)
354
- end if cfg['loggers']
370
+ cfg['loggers'].each do |logger_name|
371
+ logger = Kernel.const_get(logger_name).new(cfg)
372
+ Spectre::Logging.add(logger)
373
+ end if cfg['loggers']
355
374
 
356
- specs = Spectre.specs(cfg['specs'], cfg['tags'])
375
+ specs = Spectre.specs(cfg['specs'], cfg['tags'])
357
376
 
358
- unless specs.any?
359
- puts "No specs found in #{Dir.pwd}"
360
- exit 1
361
- end
377
+ unless specs.any?
378
+ puts "No specs found in #{Dir.pwd}"
379
+ exit 1
380
+ end
362
381
 
363
- run_infos = Spectre::Runner.new.run(specs)
382
+ run_infos = Spectre::Runner.new.run(specs)
364
383
 
365
- cfg['reporters'].each do |reporter|
366
- reporter = Kernel.const_get(reporter).new(cfg)
367
- reporter.report(run_infos)
368
- end
384
+ cfg['reporters'].each do |reporter|
385
+ reporter = Kernel.const_get(reporter).new(cfg)
386
+ reporter.report(run_infos)
387
+ end
369
388
 
370
- errors = run_infos.select { |x| nil != x.error or nil != x.failure }
389
+ errors = run_infos.select { |x| nil != x.error or nil != x.failure }
371
390
 
372
- exit 0 if cfg['ignore_failure'] or not errors.any?
391
+ exit 0 if cfg['ignore_failure'] or not errors.any?
373
392
 
374
- exit 1
393
+ exit 1
394
+ end
375
395
  end
376
396
 
377
397
 
@@ -418,10 +438,12 @@ if 'cleanup' == action
418
438
 
419
439
  Dir.glob(log_file_pattern).each do |log_file|
420
440
  File.delete(log_file)
441
+ puts "#{log_file} deleted"
421
442
  end
422
443
 
423
444
  Dir.glob(File.join cfg['out_path'], '/*').each do |out_file|
424
445
  File.delete(out_file)
446
+ puts "#{out_file} deleted"
425
447
  end
426
448
  end
427
449
 
@@ -504,7 +526,7 @@ SAMPLE_SPEC = %[describe '<subject>' do
504
526
  end
505
527
 
506
528
  expect 'a message to exist' do
507
- response.json.message.should_not_be nil
529
+ response.json.message.should_not_be_empty
508
530
  end
509
531
  end
510
532
  end