sus 0.29.0 → 0.30.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bin/sus +1 -0
- data/bin/sus-host +1 -0
- data/bin/sus-parallel +1 -0
- data/bin/sus-tree +1 -0
- data/lib/sus/assertions.rb +1 -1
- data/lib/sus/context.rb +52 -0
- data/lib/sus/have.rb +4 -3
- data/lib/sus/include_context.rb +5 -0
- data/lib/sus/it_behaves_like.rb +2 -2
- data/lib/sus/shared.rb +9 -1
- data/lib/sus/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1b91ed35726c8afcbc97fd2c73ea28d433874f7976958b26beebd9f4ed1dfe4
|
4
|
+
data.tar.gz: 2295e4817295a52265e94c4eadf708f15b4502ecd40e42b76a44570c3f7c5f2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 821e42e75cb7628974b6e10b036eb222aa35adfbafb25dc7b773b7b2ba8714c1a292c9ab539763567e1a1010f814aeada965b406eb77969a2f78c6dbf59c82e1
|
7
|
+
data.tar.gz: 44a648f339a1a947037bdfde3a5e84f875dc9fb5b018133b8e269c572f33ff90dd05c9bfe86f233df60b6ae7357b08ec62523841dddc1cd137327c445d13258e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bin/sus
CHANGED
data/bin/sus-host
CHANGED
data/bin/sus-parallel
CHANGED
data/bin/sus-tree
CHANGED
data/lib/sus/assertions.rb
CHANGED
@@ -60,7 +60,7 @@ module Sus
|
|
60
60
|
# The absolute orientation of this set of assertions, i.e. whether the assertions are expected to pass or fail regardless of the parent. Used for correctly formatting the output.
|
61
61
|
attr :orientation
|
62
62
|
|
63
|
-
# Whether this set of assertions is isolated from the parent. This is used to ensure
|
63
|
+
# Whether this set of assertions is isolated from the parent. This is used to ensure that any deferred assertions are competed before the parent is completed. This is used by `receive` assertions which are deferred until the user code of the test has completed.
|
64
64
|
attr :isolated
|
65
65
|
|
66
66
|
# Distinct is used to identify a set of assertions as a single statement for the purpose of user feedback. It's used by top level ensure statements to ensure that error messages are captured and reported on those statements.
|
data/lib/sus/context.rb
CHANGED
@@ -75,5 +75,57 @@ module Sus
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
# Include an around method to the context class, that invokes the given block before running the test.
|
80
|
+
#
|
81
|
+
# Before hooks are called in the reverse order they are defined, in other words the last defined before hook is called first.
|
82
|
+
#
|
83
|
+
# @parameter hook [Proc] The block to execute before each test.
|
84
|
+
def before(&hook)
|
85
|
+
wrapper = Module.new
|
86
|
+
|
87
|
+
wrapper.define_method(:around) do |&block|
|
88
|
+
instance_exec(&hook)
|
89
|
+
super(&block)
|
90
|
+
end
|
91
|
+
|
92
|
+
self.include(wrapper)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Include an around method to the context class, that invokes the given block after running the test.
|
96
|
+
#
|
97
|
+
# After hooks are called in the order they are defined, in other words the last defined after hook is called last.
|
98
|
+
#
|
99
|
+
# @parameter hook [Proc] The block to execute after each test. An `error` argument is passed if the test failed with an exception.
|
100
|
+
def after(&hook)
|
101
|
+
wrapper = Module.new
|
102
|
+
|
103
|
+
wrapper.define_method(:around) do |&block|
|
104
|
+
error = nil
|
105
|
+
|
106
|
+
super(&block)
|
107
|
+
rescue => error
|
108
|
+
raise
|
109
|
+
ensure
|
110
|
+
instance_exec(error, &hook)
|
111
|
+
end
|
112
|
+
|
113
|
+
self.include(wrapper)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Add an around hook to the context class.
|
117
|
+
#
|
118
|
+
# Around hooks are called in the reverse order they are defined.
|
119
|
+
#
|
120
|
+
# The top level `around` implementation invokes before and after hooks.
|
121
|
+
#
|
122
|
+
# @paremeter block [Proc] The block to execute around each test.
|
123
|
+
def around(&block)
|
124
|
+
wrapper = Module.new
|
125
|
+
|
126
|
+
wrapper.define_method(:around, &block)
|
127
|
+
|
128
|
+
self.include(wrapper)
|
129
|
+
end
|
78
130
|
end
|
79
131
|
end
|
data/lib/sus/have.rb
CHANGED
@@ -19,7 +19,8 @@ module Sus
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def call(assertions, subject)
|
22
|
-
assertions
|
22
|
+
# We want to group all the assertions in to a distinct group:
|
23
|
+
assertions.nested(self, distinct: true) do |assertions|
|
23
24
|
assertions.assert(subject.key?(@name), "has key")
|
24
25
|
if @predicate
|
25
26
|
Expect.new(assertions, subject[@name]).to(@predicate)
|
@@ -39,7 +40,7 @@ module Sus
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def call(assertions, subject)
|
42
|
-
assertions.nested(self) do |assertions|
|
43
|
+
assertions.nested(self, distinct: true) do |assertions|
|
43
44
|
assertions.assert(subject.respond_to?(@name), "has attribute")
|
44
45
|
if @predicate
|
45
46
|
Expect.new(assertions, subject.public_send(@name)).to(@predicate)
|
@@ -61,7 +62,7 @@ module Sus
|
|
61
62
|
index = 0
|
62
63
|
|
63
64
|
subject.each do |value|
|
64
|
-
assertions.nested("[#{index}] = #{value.inspect}") do |assertions|
|
65
|
+
assertions.nested("[#{index}] = #{value.inspect}", distinct: true) do |assertions|
|
65
66
|
@predicate&.call(assertions, value)
|
66
67
|
end
|
67
68
|
|
data/lib/sus/include_context.rb
CHANGED
@@ -7,6 +7,11 @@ require_relative 'context'
|
|
7
7
|
|
8
8
|
module Sus
|
9
9
|
module Context
|
10
|
+
# Include a shared context into the current context, along with any arguments or options.
|
11
|
+
#
|
12
|
+
# @parameter shared [Sus::Shared] The shared context to include.
|
13
|
+
# @parameter arguments [Array] The arguments to pass to the shared context.
|
14
|
+
# @parameter options [Hash] The options to pass to the shared context.
|
10
15
|
def include_context(shared, *arguments, **options)
|
11
16
|
self.class_exec(*arguments, **options, &shared.block)
|
12
17
|
end
|
data/lib/sus/it_behaves_like.rb
CHANGED
@@ -18,12 +18,12 @@ module Sus
|
|
18
18
|
base.description = shared.name
|
19
19
|
base.identity = Identity.nested(parent.identity, base.description, unique: unique)
|
20
20
|
base.set_temporary_name("#{self}[#{base.description}]")
|
21
|
-
|
21
|
+
|
22
22
|
# User provided block is evaluated first, so that it can provide default behaviour for the shared context:
|
23
23
|
if block_given?
|
24
24
|
base.class_exec(*arguments, &block)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
base.class_exec(*arguments, &shared.block)
|
28
28
|
return base
|
29
29
|
end
|
data/lib/sus/shared.rb
CHANGED
@@ -11,13 +11,21 @@ module Sus
|
|
11
11
|
attr_accessor :block
|
12
12
|
|
13
13
|
def self.build(name, block)
|
14
|
-
base =
|
14
|
+
base = Module.new
|
15
15
|
base.extend(Shared)
|
16
16
|
base.name = name
|
17
17
|
base.block = block
|
18
18
|
|
19
19
|
return base
|
20
20
|
end
|
21
|
+
|
22
|
+
def included(base)
|
23
|
+
base.class_exec(&self.block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def prepended(base)
|
27
|
+
base.class_exec(&self.block)
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
31
|
def self.Shared(name, &block)
|
data/lib/sus/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2024-07-
|
41
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
42
42
|
dependencies: []
|
43
43
|
description:
|
44
44
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|