spectre-core 1.12.2 → 1.12.3

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: b85338c15a8c29d520ed02d2e6816a64c579b6edd654f3d047fbeddb4a5c0ea3
4
- data.tar.gz: 7be4646412f7dd3a971b21269215cddff5398cc12a50cd42dcd78a6bb70bf012
3
+ metadata.gz: c90860f8fafa6a00e51d72bfe917ea12b6ccf5d040d0696ab2701d0222375930
4
+ data.tar.gz: 40b26f956b3b9f363b2e87eb913542f1c57ef6cf9981035fcd54b42b765f5d42
5
5
  SHA512:
6
- metadata.gz: 043d7b2bda42acf5687f09ce9468c8b3ce01566c5a61d3d1c753b9d61a126898b883f00b67be67d6d61600a85143475e8b041b31fdf42f02dee5aca48260037c
7
- data.tar.gz: 890154e9fabf2664d50289f5eeb212cd9ea508a967341d9b27a2ad5dd329600542a168352274d4a0ca09dbe9aa91f3bc22e6c855d36a80e1219ccac9132dd047
6
+ metadata.gz: 93f9d8f9cd6266c53e6f91aab1d80faf3d1ae07550bf97a489e25e2597e57d8fea05b2c26637513bd80fd5824bad145f5121d25bd5a53c3c02302895a7cf9f33
7
+ data.tar.gz: 32f36474db3f486a6f36ea02ec0c2291e300be67f5f6eb13ce40e73ae0af19db56cd7a34b22ec3c18cae07f3de14f4f90ccbda03f61eed3a3a1a0ff51dfb789e
data/exe/spectre CHANGED
@@ -72,9 +72,10 @@ DEFAULT_CONFIG = {
72
72
 
73
73
 
74
74
  cmd_options = {}
75
+ property_overrides = {}
75
76
 
76
77
  opt_parser = OptionParser.new do |opts|
77
- opts.banner = %{Spectre #{Spectre::VERSION}
78
+ opts.banner = %{Spectre #{Spectre::VERSION}
78
79
 
79
80
  Usage: spectre [command] [options]
80
81
 
@@ -83,6 +84,7 @@ Commands:
83
84
  run Run specs (default)
84
85
  show Print current environment settings
85
86
  dump Dumps the given environment in YAML format to console
87
+ cleanup Will remove all generated files (e.g. logs and reports)
86
88
  init Initializes a new spectre project
87
89
 
88
90
  Specific options:}
@@ -132,17 +134,24 @@ Specific options:}
132
134
  end
133
135
 
134
136
  opts.on('-p KEY=VAL', '--property KEY=VAL', "Override config option. Use `spectre show` to get list of available options") do |option|
135
- key, val = option.split '='
136
- val = val.split ',' if DEFAULT_CONFIG[key].is_a? Array
137
- val = ['true', '1'].include? val if [true, false].include? DEFAULT_CONFIG[key]
137
+ key, val = option.split('=')
138
+ val = val.split(',') if DEFAULT_CONFIG[key].is_a? Array
139
+ val = ['true', '1'].include? val if [true, false].include?(DEFAULT_CONFIG[key])
138
140
  val = val.to_i if DEFAULT_CONFIG[key].is_a? Integer
139
- cmd_options[key] = val
140
141
 
141
- curr_opt = cmd_options
142
- (key.split '.').each do |k|
143
- curr_opt[k] = {} unless curr_opt.key? k
142
+ opt_path = key.split('.')
143
+
144
+ curr_opt = property_overrides
145
+
146
+ opt_path.each_with_index do |part, i|
147
+ if i == opt_path.count-1
148
+ curr_opt[part] = val
149
+ break
150
+ end
151
+
152
+ curr_opt[part] = {} unless curr_opt.key?(part)
153
+ curr_opt = curr_opt[part]
144
154
  end
145
- curr_opt = val
146
155
  end
147
156
 
148
157
  opts.separator "\nCommon options:"
@@ -187,7 +196,6 @@ end
187
196
 
188
197
  cfg.deep_merge! cmd_options
189
198
 
190
-
191
199
  ###########################################
192
200
  # Load Environment
193
201
  ###########################################
@@ -224,7 +232,10 @@ cfg['env_partial_patterns'].each do |pattern|
224
232
  end
225
233
 
226
234
  env = envs[cfg['environment']]
227
- cfg.merge! env if env
235
+ cfg.deep_merge! env if env
236
+
237
+ # Merge property overrides after environment load to give it higher priority
238
+ cfg.deep_merge! property_overrides
228
239
 
229
240
 
230
241
  String.colored! if cfg['colored']
@@ -392,6 +403,24 @@ if 'dump' == action
392
403
  end
393
404
 
394
405
 
406
+ ###########################################
407
+ # Cleanup
408
+ ###########################################
409
+
410
+
411
+ if 'cleanup' == action
412
+ log_file_pattern = cfg['log_file'].gsub('<date>', '*')
413
+
414
+ Dir.glob(log_file_pattern).each do |log_file|
415
+ File.delete(log_file)
416
+ end
417
+
418
+ Dir.glob(File.join cfg['out_path'], '/*').each do |out_file|
419
+ File.delete(out_file)
420
+ end
421
+ end
422
+
423
+
395
424
  ###########################################
396
425
  # Init
397
426
  ###########################################
@@ -52,7 +52,7 @@ module Spectre
52
52
  end
53
53
 
54
54
  def should_not_be_empty
55
- raise AssertionFailure.new('The list is empty', 'nil')
55
+ raise AssertionFailure.new('The value does not exist', 'nil')
56
56
  end
57
57
  end
58
58
 
@@ -247,7 +247,7 @@ module Spectre
247
247
  raise AssertionFailure.new(e.message, e.expected, e.actual, desc), cause: nil
248
248
  rescue Exception => e
249
249
  Logger.log_status(desc, Logger::Status::ERROR)
250
- raise AssertionFailure.new("An unexpected error occured during expectation: #{e.message}", nil, nil, desc), cause: e
250
+ raise AssertionFailure.new("An unexpected error occurred during expectation: #{e.message}", nil, nil, desc), cause: e
251
251
  end
252
252
  end
253
253
 
data/lib/spectre/curl.rb CHANGED
@@ -301,7 +301,10 @@ module Spectre::Curl
301
301
 
302
302
  req_log = "[>] #{req_id} #{req['method']} #{uri}\n"
303
303
  req_log += header_to_s(req['headers'])
304
- req_log += try_format_json(req['body'], pretty: true)
304
+
305
+ if req[:body] != nil and not req[:body].empty?
306
+ req_log += try_format_json(req['body'], pretty: true)
307
+ end
305
308
 
306
309
  @@logger.info(req_log)
307
310
 
@@ -329,7 +332,7 @@ module Spectre::Curl
329
332
 
330
333
  exit_code = wait_thr.value.exitstatus
331
334
 
332
- raise Exception.new "An error occured while executing curl:\n#{debug_log.lines.map { |x| not x.empty? }}" unless exit_code == 0
335
+ raise Exception.new "An error occurred while executing curl:\n#{debug_log.lines.map { |x| not x.empty? }}" unless exit_code == 0
333
336
 
334
337
  # Parse protocol, version, status code and status message from response
335
338
  match = /^(?<protocol>[A-Za-z0-9]+)\/(?<version>\d+\.?\d*) (?<code>\d+) (?<message>.*)/.match result
@@ -79,7 +79,7 @@ module Spectre
79
79
 
80
80
  def log_error spec, exception
81
81
  file, line = exception.backtrace[0].match(/(.*\.rb):(\d+)/).captures
82
- @file_log.error "An unexpected error occured at '#{file}:#{line}' while running spec '#{spec.name}': [#{exception.class}] #{exception.message}\n#{exception.backtrace.join "\n"}"
82
+ @file_log.error "An unexpected error occurred at '#{file}:#{line}' while running spec '#{spec.name}': [#{exception.class}] #{exception.message}\n#{exception.backtrace.join "\n"}"
83
83
  end
84
84
 
85
85
  def log_skipped spec
@@ -21,7 +21,6 @@ module Spectre::Reporter
21
21
  if run_info.failure
22
22
  report_str += " Expected #{run_info.failure.expectation}"
23
23
  report_str += " with #{run_info.data}" if run_info.data
24
- report_str += " during #{spec.context.__desc}" if spec.context.__desc
25
24
 
26
25
  report_str += " but it failed"
27
26
 
@@ -40,7 +39,7 @@ module Spectre::Reporter
40
39
  failures += 1
41
40
 
42
41
  else
43
- report_str += " but an unexpected error occured during run\n"
42
+ report_str += " but an unexpected error occurred during run\n"
44
43
  report_str += format_exception(run_info.error)
45
44
  errors += 1
46
45
  end
@@ -68,6 +67,7 @@ module Spectre::Reporter
68
67
 
69
68
  def format_title run_info
70
69
  title = run_info.spec.subject.desc
70
+ title += " #{run_info.spec.context.__desc}" if run_info.spec.context.__desc
71
71
  title += ' ' + run_info.spec.desc
72
72
  title += " (#{'%.3f' % run_info.duration}s)"
73
73
  title += " [#{run_info.spec.name}]"
@@ -1,3 +1,5 @@
1
+ require 'CGI'
2
+
1
3
  # https://llg.cubic.org/docs/junit/
2
4
  # Azure mappings: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=junit%2Cyaml
3
5
 
@@ -22,11 +24,11 @@ module Spectre::Reporter
22
24
  errors = run_infos.select { |x| x.error != nil }
23
25
  skipped = run_infos.select { |x| x.skipped? }
24
26
 
25
- xml_str += '<testsuite package="' + subject.desc + '" id="' + suite_id.to_s + '" name="' + subject.desc + '" timestamp="' + datetime + '" tests="' + run_infos.count.to_s + '" failures="' + failures.count.to_s + '" errors="' + errors.count.to_s + '" skipped="' + skipped.count.to_s + '">'
27
+ xml_str += '<testsuite package="' + CGI::escapeHTML(subject.desc) + '" id="' + CGI::escapeHTML(suite_id.to_s) + '" name="' + CGI::escapeHTML(subject.desc) + '" timestamp="' + datetime + '" tests="' + run_infos.count.to_s + '" failures="' + failures.count.to_s + '" errors="' + errors.count.to_s + '" skipped="' + skipped.count.to_s + '">'
26
28
  suite_id += 1
27
29
 
28
30
  run_infos.each do |run_info|
29
- xml_str += '<testcase classname="' + run_info.spec.file.to_s + '" name="' + run_info.spec.desc + '" timestamp="' + run_info.started.to_s + '" time="' + ('%.3f' % run_info.duration) + '">'
31
+ xml_str += '<testcase classname="' + CGI::escapeHTML(run_info.spec.file.to_s) + '" name="' + CGI::escapeHTML(run_info.spec.desc) + '" timestamp="' + run_info.started.to_s + '" time="' + ('%.3f' % run_info.duration) + '">'
30
32
 
31
33
  if run_info.failure and !run_info.failure.cause
32
34
  failure_message = "Expected #{run_info.failure.expectation}"
@@ -38,7 +40,7 @@ module Spectre::Reporter
38
40
  failure_message += " but it failed"
39
41
  end
40
42
 
41
- xml_str += '<failure message="' + failure_message.gsub('"', '`') + '"></failure>'
43
+ xml_str += '<failure message="' + CGI::escapeHTML(failure_message.gsub('"', '`')) + '"></failure>'
42
44
  end
43
45
 
44
46
 
@@ -49,7 +51,7 @@ module Spectre::Reporter
49
51
  failure_message = error.message
50
52
  text = error.backtrace.join "\n"
51
53
 
52
- xml_str += '<error message="' + failure_message.gsub('"', '`') + '" type="' + type + '">'
54
+ xml_str += '<error message="' + CGI::escapeHTML(failure_message.gsub('"', '`')) + '" type="' + type + '">'
53
55
  xml_str += '<![CDATA[' + text + ']]>'
54
56
  xml_str += '</error>'
55
57
  end
data/lib/spectre.rb CHANGED
@@ -2,7 +2,7 @@ module Spectre
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 12
5
- TINY = 2
5
+ TINY = 3
6
6
  end
7
7
 
8
8
  VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectre-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.2
4
+ version: 1.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neubauer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ectoplasm
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 1.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jsonpath
29
29
  requirement: !ruby/object:Gem::Requirement