spectre-core 1.12.3 → 1.12.4

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: c90860f8fafa6a00e51d72bfe917ea12b6ccf5d040d0696ab2701d0222375930
4
- data.tar.gz: 40b26f956b3b9f363b2e87eb913542f1c57ef6cf9981035fcd54b42b765f5d42
3
+ metadata.gz: 9d2cb2622682713c0fc37e7c0e679aa0d93f01ac9af389c8430496a272608038
4
+ data.tar.gz: 8b313cd7952c0b9e4baf9e8f0cec0af397d1f8cf8fc25760204714f687718df8
5
5
  SHA512:
6
- metadata.gz: 93f9d8f9cd6266c53e6f91aab1d80faf3d1ae07550bf97a489e25e2597e57d8fea05b2c26637513bd80fd5824bad145f5121d25bd5a53c3c02302895a7cf9f33
7
- data.tar.gz: 32f36474db3f486a6f36ea02ec0c2291e300be67f5f6eb13ce40e73ae0af19db56cd7a34b22ec3c18cae07f3de14f4f90ccbda03f61eed3a3a1a0ff51dfb789e
6
+ metadata.gz: c3e939b9e9851ece96d27e31d19fa7f4c5b26bd9141e28e2e5964b5f20ed1f9c9b0f4a77800b87c411d1c271d0b4acf1afa1f50359e832842e241a1ba536b811
7
+ data.tar.gz: d105a5a9924cba80b028790a538945087ef0e19a30763e619b712c1d7b31b54259a03504a5a52d1f1cc24be6a03f1e8185d499ed9e7343a17655c4336f22dd40
data/exe/spectre CHANGED
@@ -9,6 +9,11 @@ require 'ectoplasm'
9
9
 
10
10
  require_relative '../lib/spectre'
11
11
 
12
+ def load_yaml file_path
13
+ yaml = File.read(file_path)
14
+ YAML.safe_load(yaml, aliases: true)
15
+ end
16
+
12
17
 
13
18
  DEFAULT_CONFIG = {
14
19
  'config_file' => './spectre.yml',
@@ -182,14 +187,14 @@ cfg.deep_merge! DEFAULT_CONFIG
182
187
  global_config_file = File.join File.expand_path('~'), '.spectre'
183
188
 
184
189
  if File.exists? global_config_file
185
- global_options = YAML.load_file(global_config_file)
190
+ global_options = load_yaml(global_config_file)
186
191
  cfg.deep_merge! global_options if global_options
187
192
  end
188
193
 
189
194
  config_file = cmd_options['config_file'] || cfg['config_file']
190
195
 
191
196
  if File.exists? config_file
192
- file_options = YAML.load_file(config_file)
197
+ file_options = load_yaml(config_file)
193
198
  cfg.deep_merge! file_options
194
199
  Dir.chdir File.dirname(config_file)
195
200
  end
@@ -205,7 +210,7 @@ envs = {}
205
210
  read_env_files = {}
206
211
  cfg['env_patterns'].each do |pattern|
207
212
  Dir.glob(pattern).each do|f|
208
- spec_env = YAML.load_file(f) || {}
213
+ spec_env = load_yaml(f) || {}
209
214
 
210
215
  name = spec_env['name'] || 'default'
211
216
 
@@ -223,7 +228,7 @@ end
223
228
  # Merge partial environment configs with existing environments
224
229
  cfg['env_partial_patterns'].each do |pattern|
225
230
  Dir.glob(pattern).each do|f|
226
- partial_env = YAML.load_file(f)
231
+ partial_env = load_yaml(f)
227
232
  name = partial_env.delete('name') || 'default'
228
233
  next unless envs.key? name
229
234
 
@@ -113,8 +113,14 @@ module Spectre
113
113
  print_line('', txt)
114
114
  end
115
115
 
116
- def log_skipped _spec
117
- print_line('', Status::SKIPPED.grey)
116
+ def log_skipped _spec, message=nil
117
+ txt = Status::SKIPPED
118
+
119
+ unless message.nil?
120
+ txt += ' - ' + message
121
+ end
122
+
123
+ print_line('', txt.grey)
118
124
  end
119
125
 
120
126
  private
@@ -82,8 +82,14 @@ module Spectre
82
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
- def log_skipped spec
86
- @file_log.warn "spec '#{spec.desc}' canceled by user"
85
+ def log_skipped spec, message=nil
86
+ txt = "spec '#{spec.desc}' skipped"
87
+
88
+ unless message.nil?
89
+ txt += ': ' + message
90
+ end
91
+
92
+ @file_log.warn txt
87
93
  end
88
94
 
89
95
  def log_status desc, status, annotation=nil
@@ -109,8 +109,8 @@ module Spectre
109
109
  delegate(:log_error, spec, exception)
110
110
  end
111
111
 
112
- def log_skipped spec
113
- delegate(:log_skipped, spec)
112
+ def log_skipped spec, message=nil
113
+ delegate(:log_skipped, spec, message)
114
114
  end
115
115
 
116
116
  def log_status desc, status, annotation=nil
@@ -1,4 +1,4 @@
1
- require 'CGI'
1
+ require 'cgi'
2
2
 
3
3
  # https://llg.cubic.org/docs/junit/
4
4
  # Azure mappings: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=junit%2Cyaml
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 = 3
5
+ TINY = 4
6
6
  end
7
7
 
8
8
  VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
@@ -48,6 +48,12 @@ module Spectre
48
48
  end
49
49
  end
50
50
 
51
+ class SpectreSkip < Interrupt
52
+ def initialize message
53
+ super message
54
+ end
55
+ end
56
+
51
57
 
52
58
  ###########################################
53
59
  # Internal Classes
@@ -252,9 +258,12 @@ module Spectre
252
258
  spec.block.call(data)
253
259
  rescue ExpectationFailure => e
254
260
  run_info.failure = e
261
+ rescue SpectreSkip => e
262
+ run_info.skipped = true
263
+ Logger.log_skipped spec, e.message
255
264
  rescue Interrupt
256
265
  run_info.skipped = true
257
- Logger.log_skipped spec
266
+ Logger.log_skipped spec, 'canceled by user'
258
267
  rescue Exception => e
259
268
  run_info.error = e
260
269
  Logger.log_error spec, e
@@ -438,9 +447,13 @@ module Spectre
438
447
  def property key, val
439
448
  Spectre::Runner.current.properties[key] = val
440
449
  end
450
+
451
+ def skip message=nil
452
+ raise SpectreSkip.new(message)
453
+ end
441
454
  end
442
455
 
443
- delegate :describe, :property, to: Spectre
456
+ delegate :describe, :property, :skip, to: Spectre
444
457
  end
445
458
 
446
459
 
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.3
4
+ version: 1.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neubauer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2022-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ectoplasm
@@ -80,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 2.5.0
83
+ version: 3.0.0
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.2.3
90
+ rubygems_version: 3.3.7
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Describe and run automated tests