sus 0.11.2 → 0.12.2

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: f878b94ac4b8236fdb411866336061b34cca3c59a9573e4cb0ef238d545ffe3d
4
- data.tar.gz: c61aaee1228f6ab7796811ee739de195a5b59cf1a014f304d08f3d64488c94ba
3
+ metadata.gz: 2d505d424da315b800a7343985c211d2cfdb9a74217fb81bd6025edec186e419
4
+ data.tar.gz: 5e94dbc0566760d20f937a87c09fa958152c79fb06656827f66e7a189dc40a0a
5
5
  SHA512:
6
- metadata.gz: 181ee960cee58bf710d7de09a6f83f72a71f01d25716d18dd386562bf2984e14f690cfa1561b298d36bc068d06676481979866f48ee2a2716866e725a9d3c07f
7
- data.tar.gz: 206fa66d07315578142b07b3802a66af629668502a2745dbf4a3f60cbebf4c8d8cc8c2edd4011397a22b7d039c753874409fe576d42890745629d4d5ac57a906
6
+ metadata.gz: 5866a210c3427c7afa83ccd6b45c2915fdff79cd0c3cec8941f8a26f7ebe32d453911be4bbd08375c78bda93ae827a840669d1d9657465feff84cfef1488db7f
7
+ data.tar.gz: 87092d555eab03db7ff1993bfea058fdb1a628cb22a2f57dc3bd63341dc29697c1444575664432d8fb277039faa6d4cbd2e78c3ab3f4fc7435be9229711eab64
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
@@ -24,7 +24,7 @@ module Sus
24
24
  @verbose = verbose
25
25
 
26
26
  if measure
27
- @clock = Clock.new
27
+ @clock = Clock.start!
28
28
  else
29
29
  @clock = nil
30
30
  end
@@ -130,6 +130,10 @@ module Sus
130
130
  end
131
131
  end
132
132
 
133
+ def inform(message)
134
+ @output.puts(:indent, :inform, inform_prefix, message)
135
+ end
136
+
133
137
  # Add deferred assertions.
134
138
  def defer(&block)
135
139
  @deferred << block
@@ -177,44 +181,23 @@ module Sus
177
181
 
178
182
  assertions = self.class.new(identity: identity, target: target, output: output, isolated: isolated, inverted: inverted, verbose: @verbose, **options)
179
183
 
180
- @clock&.start!
181
-
182
184
  output.indented do
183
185
  begin
184
186
  result = yield(assertions)
185
187
  rescue StandardError => error
186
188
  assertions.fail(error)
187
- ensure
188
- @clock&.stop!
189
189
  end
190
190
  end
191
191
 
192
- self.add(assertions)
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)
193
194
 
194
195
  return result
195
196
  end
196
197
 
198
+ # Add the child assertions which were nested to this instance.
197
199
  def add(assertions)
198
- # If the assertions should be an isolated group, make sure any deferred assertions are resolved:
199
- if assertions.isolated and assertions.deferred?
200
- assertions.resolve!
201
- end
202
-
203
- if assertions.deferred?
204
- self.defer do
205
- output.puts(:indent, assertions.target)
206
- assertions.resolve!
207
-
208
- self.add!(assertions)
209
- end
210
- else
211
- self.add!(assertions)
212
- end
213
- end
214
-
215
- private
216
-
217
- def add!(assertions)
200
+ # All child assertions should be resolved by this point:
218
201
  raise "Nested assertions must be fully resolved!" if assertions.deferred?
219
202
 
220
203
  if assertions.isolated or assertions.inverted
@@ -226,6 +209,29 @@ module Sus
226
209
  end
227
210
  end
228
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
+
229
235
  def merge!(assertions)
230
236
  @count += assertions.count
231
237
 
@@ -266,5 +272,9 @@ module Sus
266
272
  def fail_prefix
267
273
  "✗ "
268
274
  end
275
+
276
+ def inform_prefix
277
+ "ℹ "
278
+ end
269
279
  end
270
280
  end
data/lib/sus/base.rb CHANGED
@@ -34,8 +34,8 @@ module Sus
34
34
  @__assertions__.assert(...)
35
35
  end
36
36
 
37
- def refute(...)
38
- @__assertions__.refute(...)
37
+ def inform(...)
38
+ @__assertions__.inform(...)
39
39
  end
40
40
  end
41
41
 
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, **options, &block)
47
+ def expect(subject = nil, &block)
48
48
  if block_given?
49
- Expect.new(@__assertions__, block, **options)
49
+ Expect.new(@__assertions__, block)
50
50
  else
51
- Expect.new(@__assertions__, subject, **options)
51
+ Expect.new(@__assertions__, subject)
52
52
  end
53
53
  end
54
54
 
data/lib/sus/output.rb CHANGED
@@ -40,6 +40,7 @@ module Sus
40
40
  output[:passed] = output.style(:green)
41
41
  output[:failed] = output.style(:red)
42
42
  output[:error] = output.style(:red)
43
+ # output[:inform] = output.style(nil, nil, :bold)
43
44
 
44
45
  return output
45
46
  end
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.11.2"
7
+ VERSION = "0.12.2"
8
8
  end
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.11.2
4
+ version: 0.12.2
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-08-27 00:00:00.000000000 Z
41
- dependencies: []
40
+ date: 2022-08-28 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