spectre-core 2.0.3 → 2.1.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 +4 -4
- data/exe/spectre +3 -1
- data/lib/spectre/assertion.rb +6 -6
- data/lib/spectre/expectation.rb +7 -7
- data/lib/spectre/helpers.rb +1 -1
- data/lib/spectre/version.rb +1 -1
- data/lib/spectre.rb +49 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903623ea7a511af71aebe1919c91b0b298fed6819310d60a38dc8ad3fd74127d
|
4
|
+
data.tar.gz: 52e66bd3838d220bd3ab57fc91f81d3eff5c7c9c85c5651611a75e99ed133c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97ac252558b5acbc8ad88995759632f69adf7a5b8dd38e373b1f8cf176a047e89019fd568ebd02d0b6a556e6d210499f25ea3f3d7ff74ccaa00f9796d0619c09
|
7
|
+
data.tar.gz: e12befe6472a287a0d94755853e123da29066aab9aeaa8e60e5366019776638730e274f9a0e9f4d3fd87023faaa9961b51fbf9ffc5cfb66edc524f68ec54d7ce
|
data/exe/spectre
CHANGED
@@ -121,7 +121,7 @@ options = OptionParser.new do |opts|
|
|
121
121
|
'Override config option. Use `spectre show` to get list of available options') do |option|
|
122
122
|
index = option.index('=')
|
123
123
|
key = option[0...index]
|
124
|
-
val = option[index + 1..]
|
124
|
+
val = option[(index + 1)..]
|
125
125
|
|
126
126
|
val = val.split(',') if Spectre::CONFIG[key].is_a? Array
|
127
127
|
val = ['true', '1'].include? val if [true, false].include?(Spectre::CONFIG[key])
|
@@ -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 }
|
data/lib/spectre/assertion.rb
CHANGED
@@ -11,7 +11,7 @@ module Spectre
|
|
11
11
|
@val = val
|
12
12
|
end
|
13
13
|
|
14
|
-
def evaluate predicate, actual, negate
|
14
|
+
def evaluate? predicate, actual, negate
|
15
15
|
!(!negate ^ predicate.call(@val, actual))
|
16
16
|
end
|
17
17
|
|
@@ -31,8 +31,8 @@ module Spectre
|
|
31
31
|
@second = ValueWrapper.wrap(second)
|
32
32
|
end
|
33
33
|
|
34
|
-
def evaluate predicate, actual, negate
|
35
|
-
@first.evaluate(predicate, actual, negate) or @second.evaluate(predicate, actual, negate)
|
34
|
+
def evaluate? predicate, actual, negate
|
35
|
+
@first.evaluate?(predicate, actual, negate) or @second.evaluate?(predicate, actual, negate)
|
36
36
|
end
|
37
37
|
|
38
38
|
# :nodoc:
|
@@ -48,8 +48,8 @@ module Spectre
|
|
48
48
|
@second = ValueWrapper.wrap(second)
|
49
49
|
end
|
50
50
|
|
51
|
-
def evaluate predicate, actual, negate
|
52
|
-
@first.evaluate(predicate, actual, negate) and @second.evaluate(predicate, actual, negate)
|
51
|
+
def evaluate? predicate, actual, negate
|
52
|
+
@first.evaluate?(predicate, actual, negate) and @second.evaluate?(predicate, actual, negate)
|
53
53
|
end
|
54
54
|
|
55
55
|
# :nodoc:
|
@@ -98,7 +98,7 @@ module Spectre
|
|
98
98
|
@repr += " to #{method}"
|
99
99
|
@repr += expected.nil? ? ' empty' : " #{@expected}"
|
100
100
|
|
101
|
-
success = @expected.evaluate(@predicate, @actual, @negate)
|
101
|
+
success = @expected.evaluate?(@predicate, @actual, @negate)
|
102
102
|
|
103
103
|
return if success
|
104
104
|
|
data/lib/spectre/expectation.rb
CHANGED
@@ -10,7 +10,7 @@ module Spectre
|
|
10
10
|
def should_be value
|
11
11
|
predicate = proc { |expected, actual| expected.to_s == actual.to_s }
|
12
12
|
value = Spectre::Assertion::ValueWrapper.wrap(value)
|
13
|
-
success = value.evaluate(predicate, self, false)
|
13
|
+
success = value.evaluate?(predicate, self, false)
|
14
14
|
|
15
15
|
return if success
|
16
16
|
|
@@ -20,7 +20,7 @@ module Spectre
|
|
20
20
|
def should_be_empty
|
21
21
|
predicate = proc { |_, actual| actual.nil? or (actual.respond_to?(:empty?) and actual.empty?) }
|
22
22
|
value = Spectre::Assertion::ValueWrapper.wrap(nil)
|
23
|
-
success = value.evaluate(predicate, self, false)
|
23
|
+
success = value.evaluate?(predicate, self, false)
|
24
24
|
|
25
25
|
return if success
|
26
26
|
|
@@ -30,7 +30,7 @@ module Spectre
|
|
30
30
|
def should_not_be(value)
|
31
31
|
predicate = proc { |expected, actual| expected.to_s == actual.to_s }
|
32
32
|
value = Spectre::Assertion::ValueWrapper.wrap(value)
|
33
|
-
success = value.evaluate(predicate, self, true)
|
33
|
+
success = value.evaluate?(predicate, self, true)
|
34
34
|
|
35
35
|
return if success
|
36
36
|
|
@@ -40,7 +40,7 @@ module Spectre
|
|
40
40
|
def should_not_exist
|
41
41
|
predicate = proc { |expected, _| expected.respond_to? :nil? and expected.nil? }
|
42
42
|
value = Spectre::Assertion::ValueWrapper.wrap(value)
|
43
|
-
success = value.evaluate(predicate, self, true)
|
43
|
+
success = value.evaluate?(predicate, self, true)
|
44
44
|
|
45
45
|
return if success
|
46
46
|
|
@@ -50,7 +50,7 @@ module Spectre
|
|
50
50
|
def should_not_be_empty
|
51
51
|
predicate = proc { |_, actual| actual.nil? or (actual.respond_to?(:empty?) and actual.empty?) }
|
52
52
|
value = Spectre::Assertion::ValueWrapper.wrap(nil)
|
53
|
-
success = value.evaluate(predicate, self, true)
|
53
|
+
success = value.evaluate?(predicate, self, true)
|
54
54
|
|
55
55
|
return if success
|
56
56
|
|
@@ -64,7 +64,7 @@ module Spectre
|
|
64
64
|
end
|
65
65
|
|
66
66
|
value = Spectre::Assertion::ValueWrapper.wrap(value)
|
67
|
-
success = value.evaluate(predicate, self, false)
|
67
|
+
success = value.evaluate?(predicate, self, false)
|
68
68
|
|
69
69
|
return if success
|
70
70
|
|
@@ -78,7 +78,7 @@ module Spectre
|
|
78
78
|
end
|
79
79
|
|
80
80
|
value = Spectre::Assertion::ValueWrapper.wrap(value)
|
81
|
-
success = value.evaluate(predicate, self, true)
|
81
|
+
success = value.evaluate?(predicate, self, true)
|
82
82
|
|
83
83
|
return if success
|
84
84
|
|
data/lib/spectre/helpers.rb
CHANGED
data/lib/spectre/version.rb
CHANGED
data/lib/spectre.rb
CHANGED
@@ -335,6 +335,12 @@ module Spectre
|
|
335
335
|
@out.puts env.to_h.pretty
|
336
336
|
end
|
337
337
|
|
338
|
+
def envs envs
|
339
|
+
@out.puts envs
|
340
|
+
.map { |env_name, _| env_name }
|
341
|
+
.join("\n")
|
342
|
+
end
|
343
|
+
|
338
344
|
def scope desc, type
|
339
345
|
if desc
|
340
346
|
colored_desc = case type
|
@@ -490,19 +496,19 @@ module Spectre
|
|
490
496
|
.select { |x| x.failures.any? }
|
491
497
|
|
492
498
|
failed.each_with_index do |eval, eval_idx|
|
493
|
-
output += if failed.
|
499
|
+
output += if failed.one?
|
494
500
|
" #{eval.desc}, but"
|
495
501
|
else
|
496
502
|
" #{index}.#{eval_idx + 1}) #{eval.desc}, but"
|
497
503
|
end
|
498
504
|
|
499
|
-
if eval.failures.
|
505
|
+
if eval.failures.one?
|
500
506
|
output += " #{eval.failures.first.message}\n"
|
501
507
|
else
|
502
508
|
output += " #{eval.failures.count} failures occured\n"
|
503
509
|
|
504
510
|
eval.failures.each_with_index do |fail, fail_idx|
|
505
|
-
output += if failed.
|
511
|
+
output += if failed.one?
|
506
512
|
" #{index}.#{fail_idx + 1}) #{fail.message}\n"
|
507
513
|
else
|
508
514
|
" #{index}.#{eval_idx + 1}.#{fail_idx + 1}) #{fail.message}\n"
|
@@ -554,6 +560,8 @@ module Spectre
|
|
554
560
|
{
|
555
561
|
name: spec.name,
|
556
562
|
desc: spec.desc,
|
563
|
+
subj: spec.root.desc,
|
564
|
+
ctxt: spec.parent.desc,
|
557
565
|
tags: spec.tags,
|
558
566
|
file: spec.file,
|
559
567
|
data: spec.data,
|
@@ -586,6 +594,12 @@ module Spectre
|
|
586
594
|
@out.puts env.to_json
|
587
595
|
end
|
588
596
|
|
597
|
+
def envs envs
|
598
|
+
@out.puts envs
|
599
|
+
.map { |env_name, _| env_name }
|
600
|
+
.to_json
|
601
|
+
end
|
602
|
+
|
589
603
|
def scope desc, type
|
590
604
|
id = SecureRandom.hex(8)
|
591
605
|
|
@@ -779,7 +793,7 @@ module Spectre
|
|
779
793
|
|
780
794
|
# :stopdoc:
|
781
795
|
|
782
|
-
attr_reader :name, :parent, :type, :logs, :error,
|
796
|
+
attr_reader :name, :parent, :context, :type, :logs, :error,
|
783
797
|
:evaluations, :started, :finished, :properties, :data
|
784
798
|
|
785
799
|
##
|
@@ -807,7 +821,18 @@ module Spectre
|
|
807
821
|
@threads = {}
|
808
822
|
|
809
823
|
@name = parent.name
|
810
|
-
|
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
|
811
836
|
|
812
837
|
@bag = OpenStruct.new(bag)
|
813
838
|
|
@@ -956,20 +981,22 @@ module Spectre
|
|
956
981
|
define_method(method) do |evaluation, &block|
|
957
982
|
desc = "#{method} #{evaluation}"
|
958
983
|
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
984
|
+
evaluation = if block
|
985
|
+
EvaluationContext.new(@engine, desc, &block)
|
986
|
+
else
|
987
|
+
EvaluationContext.new(@engine, desc) do
|
988
|
+
unless evaluation.failure.nil?
|
989
|
+
@failures << Failure.new(
|
990
|
+
evaluation.failure,
|
991
|
+
evaluation.call_location
|
992
|
+
)
|
993
|
+
end
|
994
|
+
end
|
995
|
+
end
|
996
|
+
|
997
|
+
@evaluations << evaluation
|
971
998
|
|
972
|
-
raise AbortException if method == :assert and
|
999
|
+
raise AbortException if method == :assert and evaluation.failures.any?
|
973
1000
|
end
|
974
1001
|
end
|
975
1002
|
|
@@ -1410,7 +1437,7 @@ module Spectre
|
|
1410
1437
|
DEFAULT_ENV_NAME = 'default'
|
1411
1438
|
|
1412
1439
|
class Engine
|
1413
|
-
attr_reader :env, :formatter, :config, :contexts, :mixins, :collections, :resources
|
1440
|
+
attr_reader :env, :environments, :formatter, :config, :contexts, :mixins, :collections, :resources
|
1414
1441
|
|
1415
1442
|
@@current = nil
|
1416
1443
|
@@modules = []
|
@@ -1665,8 +1692,9 @@ module Spectre
|
|
1665
1692
|
|
1666
1693
|
patterns.each do |pattern|
|
1667
1694
|
Dir.glob(pattern).each do |file|
|
1668
|
-
|
1669
|
-
|
1695
|
+
abs_path = File.absolute_path(file)
|
1696
|
+
content = File.read abs_path
|
1697
|
+
instance_eval(content, abs_path, 1)
|
1670
1698
|
end
|
1671
1699
|
end
|
1672
1700
|
|
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.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neubauer
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: debug
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.6.
|
116
|
+
rubygems_version: 3.6.9
|
117
117
|
specification_version: 4
|
118
118
|
summary: Describe and run automated tests
|
119
119
|
test_files: []
|