spectre-core 2.0.2 → 2.1.0

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: 5d6bfa4c7b785703255f43fdaaade74aa82f8c3003d44da6dae545b079202d69
4
- data.tar.gz: 05c8e137b67850cd821ba2811efbfd21c8773aec9872d851b47d5be7fbf30926
3
+ metadata.gz: 3f4f326a4af327d079fbf3ec5d7dc1e249432b975c4192246d214430c99a3b03
4
+ data.tar.gz: 01cd31db52a056f496111ddae40fbb8ceb0fcd6728e3aec26f29306b83c49d7f
5
5
  SHA512:
6
- metadata.gz: 9ed23bd680972abbf3ddad4ed32c2cd538c5af2716fc7a1758dd267edcef3c88a8f8fe3dc4b3d06ba8d30d2e4ad66a047f8841acb67c068b5f80dd42b4ec2a2f
7
- data.tar.gz: c00eaa92f41b44472ab3cb31f1ee0f5b2a0f09652b5720f99e746e962a4b0106c19d5c201fc8045980766473345a5640c392bca6d771052d83d073bdecac3f62
6
+ metadata.gz: 96f973c643e9e670ec791b433834fa394ee5814acc0534b52ddd09b47f9ddc46b4c50900a66ab7ba453ab3fb64c97ffa4e0a7f202fd53640eb51b6cb229ca463
7
+ data.tar.gz: 3d68d5b96ee5e93bdc67e646498b606ab78dbe359faa3729993c6a13ee95e240688a5a89586f279a593d5b908b4c8db80472bcf5438432a3658dc7b4f3160483
data/exe/spectre CHANGED
@@ -187,6 +187,8 @@ when 'run', 'ru'
187
187
  engine.report(runs)
188
188
  when 'env', 'en'
189
189
  engine.formatter.environment(engine.env)
190
+ when 'envs'
191
+ engine.formatter.envs(engine.environments)
190
192
  when 'mixins', 'mi', 'mx'
191
193
  search = ARGV.first
192
194
  mixins = engine.mixins.select { |x| search.nil? or x.include? search }
@@ -1,3 +1,3 @@
1
1
  module Spectre
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
data/lib/spectre.rb CHANGED
@@ -194,10 +194,7 @@ module Spectre
194
194
  def initialize(config, **)
195
195
  log_file = config['log_file']
196
196
 
197
- if log_file.is_a? String
198
- log_file = log_file.gsub('<date>', DateTime.now.strftime('%Y-%m-%d_%H%M%S%3N'))
199
- FileUtils.mkdir_p(File.dirname(log_file))
200
- end
197
+ FileUtils.mkdir_p(File.dirname(log_file)) if log_file.is_a? String
201
198
 
202
199
  super(log_file, **)
203
200
 
@@ -338,6 +335,12 @@ module Spectre
338
335
  @out.puts env.to_h.pretty
339
336
  end
340
337
 
338
+ def envs envs
339
+ @out.puts envs
340
+ .map { |env_name, _| env_name }
341
+ .join("\n")
342
+ end
343
+
341
344
  def scope desc, type
342
345
  if desc
343
346
  colored_desc = case type
@@ -557,6 +560,8 @@ module Spectre
557
560
  {
558
561
  name: spec.name,
559
562
  desc: spec.desc,
563
+ subj: spec.root.desc,
564
+ ctxt: spec.parent.desc,
560
565
  tags: spec.tags,
561
566
  file: spec.file,
562
567
  data: spec.data,
@@ -589,6 +594,12 @@ module Spectre
589
594
  @out.puts env.to_json
590
595
  end
591
596
 
597
+ def envs envs
598
+ @out.puts envs
599
+ .map { |env_name, _| env_name }
600
+ .to_json
601
+ end
602
+
592
603
  def scope desc, type
593
604
  id = SecureRandom.hex(8)
594
605
 
@@ -782,7 +793,7 @@ module Spectre
782
793
 
783
794
  # :stopdoc:
784
795
 
785
- attr_reader :name, :parent, :type, :logs, :error,
796
+ attr_reader :name, :parent, :context, :type, :logs, :error,
786
797
  :evaluations, :started, :finished, :properties, :data
787
798
 
788
799
  ##
@@ -810,7 +821,18 @@ module Spectre
810
821
  @threads = {}
811
822
 
812
823
  @name = parent.name
813
- @name += "-#{type}" unless type == :spec
824
+
825
+ # If the run type is an actual spec, the context
826
+ # of the run is its parent +Specification+ 's parent.
827
+ if type == :spec
828
+ @context = parent.parent
829
+ else
830
+ # Otherwise the run context is the parent itself
831
+ # This is the case when a setup or teardown block
832
+ # is executet, which uses its own run context.
833
+ @context = parent
834
+ @name += "-#{type}"
835
+ end
814
836
 
815
837
  @bag = OpenStruct.new(bag)
816
838
 
@@ -1413,7 +1435,7 @@ module Spectre
1413
1435
  DEFAULT_ENV_NAME = 'default'
1414
1436
 
1415
1437
  class Engine
1416
- attr_reader :env, :formatter, :config, :contexts, :mixins, :collections, :resources
1438
+ attr_reader :env, :environments, :formatter, :config, :contexts, :mixins, :collections, :resources
1417
1439
 
1418
1440
  @@current = nil
1419
1441
  @@modules = []
@@ -1508,6 +1530,11 @@ module Spectre
1508
1530
  @config['modules'].concat(config.delete('modules')) if config.key? 'modules'
1509
1531
  @config.deep_merge!(config)
1510
1532
 
1533
+ # Replace log filename placeholders
1534
+ if @config['log_file'].respond_to? :gsub!
1535
+ @config['log_file'].gsub!('<date>', DateTime.now.strftime('%Y-%m-%d_%H%M%S%3N'))
1536
+ end
1537
+
1511
1538
  # Set env before loading specs in order to make it available in spec definitions
1512
1539
  @env = @config.to_recursive_struct
1513
1540
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectre-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neubauer
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-25 00:00:00.000000000 Z
10
+ date: 2025-03-27 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: debug