sus 0.12.0 → 0.13.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 +8 -0
- data/lib/sus/assertions.rb +28 -26
- data/lib/sus/be_within.rb +3 -1
- data/lib/sus/expect.rb +3 -3
- data/lib/sus/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +45 -3
- 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: beb15dd70f3fd10ea7d5485648b632944450255950ecbbd0c02fbd10aa533933
|
4
|
+
data.tar.gz: 4cc4f588633c0dee5211f39dec34224f78f44a47c1720c74c4a3fc90df9c7671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0292a0378064908cfff1ca760f09f2bb64f1131835ca7fafae02e1120726af7cd0575a240516392b817133dde4c444e18b0962ac5e381c761c5b98c325696ce9'
|
7
|
+
data.tar.gz: 54c3cd3c3116562271bc4c1f68172bc9fa43a3a8881bca00033d94ebd26b9a633b39897631a00a9dc90e0fef1b2c82affde754a74f644a95680080379b16d258
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bin/sus
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# require 'stackprof'
|
4
|
+
# StackProf.start(mode: :wall, interval: 10)
|
5
|
+
|
3
6
|
require_relative '../lib/sus/config'
|
4
7
|
config = Sus::Config.load
|
5
8
|
|
@@ -20,6 +23,11 @@ config.before_tests(assertions)
|
|
20
23
|
registry.call(assertions)
|
21
24
|
config.after_tests(assertions)
|
22
25
|
|
26
|
+
# StackProf.stop
|
27
|
+
# StackProf.results('sus.stackprof')
|
28
|
+
#
|
29
|
+
# $ stackprof sus.stackprof --text --limit 10
|
30
|
+
|
23
31
|
if assertions.failed.any?
|
24
32
|
exit(1)
|
25
33
|
end
|
data/lib/sus/assertions.rb
CHANGED
@@ -24,7 +24,7 @@ module Sus
|
|
24
24
|
@verbose = verbose
|
25
25
|
|
26
26
|
if measure
|
27
|
-
@clock = Clock.
|
27
|
+
@clock = Clock.start!
|
28
28
|
else
|
29
29
|
@clock = nil
|
30
30
|
end
|
@@ -181,44 +181,23 @@ module Sus
|
|
181
181
|
|
182
182
|
assertions = self.class.new(identity: identity, target: target, output: output, isolated: isolated, inverted: inverted, verbose: @verbose, **options)
|
183
183
|
|
184
|
-
@clock&.start!
|
185
|
-
|
186
184
|
output.indented do
|
187
185
|
begin
|
188
186
|
result = yield(assertions)
|
189
187
|
rescue StandardError => error
|
190
188
|
assertions.fail(error)
|
191
|
-
ensure
|
192
|
-
@clock&.stop!
|
193
189
|
end
|
194
190
|
end
|
195
191
|
|
196
|
-
|
192
|
+
# Some assertions are deferred until the end of the test, e.g. expecting a method to be called. This scope is managed by the {add} method. If there are no deferred assertions, then we can add the child assertions right away. Otherwise, we append the child assertions to our own list of deferred assertions. When an assertions instance is marked as `isolated`, it will force all deferred assertions to be resolved. It's also at this time, we should conclude measuring the duration of the test.
|
193
|
+
assertions.resolve_into(self)
|
197
194
|
|
198
195
|
return result
|
199
196
|
end
|
200
197
|
|
198
|
+
# Add the child assertions which were nested to this instance.
|
201
199
|
def add(assertions)
|
202
|
-
#
|
203
|
-
if assertions.isolated and assertions.deferred?
|
204
|
-
assertions.resolve!
|
205
|
-
end
|
206
|
-
|
207
|
-
if assertions.deferred?
|
208
|
-
self.defer do
|
209
|
-
output.puts(:indent, assertions.target)
|
210
|
-
assertions.resolve!
|
211
|
-
|
212
|
-
self.add!(assertions)
|
213
|
-
end
|
214
|
-
else
|
215
|
-
self.add!(assertions)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
private
|
220
|
-
|
221
|
-
def add!(assertions)
|
200
|
+
# All child assertions should be resolved by this point:
|
222
201
|
raise "Nested assertions must be fully resolved!" if assertions.deferred?
|
223
202
|
|
224
203
|
if assertions.isolated or assertions.inverted
|
@@ -230,6 +209,29 @@ module Sus
|
|
230
209
|
end
|
231
210
|
end
|
232
211
|
|
212
|
+
def resolve_into(parent)
|
213
|
+
# If the assertions should be an isolated group, make sure any deferred assertions are resolved:
|
214
|
+
if @isolated and self.deferred?
|
215
|
+
self.resolve!
|
216
|
+
end
|
217
|
+
|
218
|
+
# Check if the child assertions are deferred, and if so, add them to our own list of deferred assertions:
|
219
|
+
if self.deferred?
|
220
|
+
parent.defer do
|
221
|
+
output.puts(:indent, @target)
|
222
|
+
self.resolve!
|
223
|
+
|
224
|
+
@clock&.stop!
|
225
|
+
parent.add(self)
|
226
|
+
end
|
227
|
+
else
|
228
|
+
@clock&.stop!
|
229
|
+
parent.add(self)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
private
|
234
|
+
|
233
235
|
def merge!(assertions)
|
234
236
|
@count += assertions.count
|
235
237
|
|
data/lib/sus/be_within.rb
CHANGED
data/lib/sus/expect.rb
CHANGED
@@ -44,11 +44,11 @@ module Sus
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class Base
|
47
|
-
def expect(subject = nil,
|
47
|
+
def expect(subject = nil, &block)
|
48
48
|
if block_given?
|
49
|
-
Expect.new(@__assertions__, block
|
49
|
+
Expect.new(@__assertions__, block)
|
50
50
|
else
|
51
|
-
Expect.new(@__assertions__, subject
|
51
|
+
Expect.new(@__assertions__, subject)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
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.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,8 +37,50 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2022-
|
41
|
-
dependencies:
|
40
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
41
|
+
dependencies:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bake-test
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.1'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.1'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bake-test-external
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: covered
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.16.6
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.16.6
|
42
84
|
description:
|
43
85
|
email:
|
44
86
|
executables:
|
metadata.gz.sig
CHANGED
Binary file
|