sus 0.37.0 → 0.37.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sus/be.rb +2 -2
- data/lib/sus/config.rb +13 -8
- data/lib/sus/context.rb +0 -22
- data/lib/sus/fixtures/temporary_directory_context.rb +9 -2
- data/lib/sus/identity.rb +1 -11
- data/lib/sus/it.rb +26 -6
- data/lib/sus/mock.rb +2 -2
- data/lib/sus/receive.rb +1 -2
- data/lib/sus/respond_to.rb +2 -2
- data/lib/sus/version.rb +1 -1
- data/readme.md +8 -0
- data/releases.md +8 -0
- data.tar.gz.sig +2 -4
- metadata +1 -1
- 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: 356b7bfa38432ef766bae5c9ef40f7e0d08cacf9423544c1226ac86c92e78f16
|
|
4
|
+
data.tar.gz: 21ea8115de9084304ad615db7d33d7facafa7255e1d3bafd408c9885ce14044e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3db361e81379abc117c1f977a979b66f6dcd1c42270fee895db1cb1d1bef0f6c64ed45fe51084de4d0e4671d6a83475cc7dc74523221340dbfeee5921bdbc8f
|
|
7
|
+
data.tar.gz: fe44089f8600b62d4255ecdaeb3b8e15060735a7ad8e5e9d78a8e5a5dfb05a63ae999b0681ccba55ce18048fa9cd5c94c8cbb221561b72328eee96b273d002f1
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/sus/be.rb
CHANGED
|
@@ -46,7 +46,7 @@ module Sus
|
|
|
46
46
|
# @parameter other [Object] Another predicate to combine.
|
|
47
47
|
# @returns [Or] A new OR predicate.
|
|
48
48
|
def |(other)
|
|
49
|
-
Or.new(self, other)
|
|
49
|
+
Or.new([self, other])
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -93,7 +93,7 @@ module Sus
|
|
|
93
93
|
# @parameter other [Object] Another predicate to combine.
|
|
94
94
|
# @returns [And] A new AND predicate.
|
|
95
95
|
def &(other)
|
|
96
|
-
And.new(self, other)
|
|
96
|
+
And.new([self, other])
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# Combine this predicate with another using OR logic.
|
data/lib/sus/config.rb
CHANGED
|
@@ -196,13 +196,16 @@ module Sus
|
|
|
196
196
|
|
|
197
197
|
# Print feedback about the test suite.
|
|
198
198
|
# @parameter output [Output] The output handler.
|
|
199
|
-
# @parameter assertions [Assertions] The assertions instance.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
count
|
|
199
|
+
# @parameter assertions [Assertions | Nil] The assertions instance.
|
|
200
|
+
# @parameter duration [Float] The total duration of the test suite.
|
|
201
|
+
# @parameter count [Integer] The number of assertions.
|
|
202
|
+
# @parameter total [Integer] The number of tests.
|
|
203
|
+
def print_test_feedback(output, assertions = nil,
|
|
204
|
+
duration: @clock.duration,
|
|
205
|
+
count: assertions.count,
|
|
206
|
+
total: assertions.total
|
|
207
|
+
)
|
|
208
|
+
rate = count / duration
|
|
206
209
|
|
|
207
210
|
if total < 10 or count < 10
|
|
208
211
|
output.puts "😭 You should write more tests and assertions!"
|
|
@@ -212,7 +215,7 @@ module Sus
|
|
|
212
215
|
end
|
|
213
216
|
|
|
214
217
|
# Check whether there is at least, on average, one assertion (or more) per test:
|
|
215
|
-
assertions_per_test =
|
|
218
|
+
assertions_per_test = count / total
|
|
216
219
|
if assertions_per_test < 1.0
|
|
217
220
|
output.puts "😩 Your tests don't have enough assertions (#{assertions_per_test.round(1)} < 1.0)!"
|
|
218
221
|
end
|
|
@@ -242,6 +245,8 @@ module Sus
|
|
|
242
245
|
end
|
|
243
246
|
end
|
|
244
247
|
|
|
248
|
+
public :print_test_feedback
|
|
249
|
+
|
|
245
250
|
# Print information about slow tests.
|
|
246
251
|
# @parameter output [Output] The output handler.
|
|
247
252
|
# @parameter assertions [Assertions] The assertions instance.
|
data/lib/sus/context.rb
CHANGED
|
@@ -24,28 +24,6 @@ module Sus
|
|
|
24
24
|
base.children = Hash.new
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
unless respond_to?(:set_temporary_name)
|
|
28
|
-
# Set a temporary name for this context.
|
|
29
|
-
# @parameter name [String] The temporary name.
|
|
30
|
-
def set_temporary_name(name)
|
|
31
|
-
# No-op.
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# @returns [String] A string representation of this context.
|
|
35
|
-
def to_s
|
|
36
|
-
(self.description || self.name).to_s
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# @returns [String] An inspect representation of this context.
|
|
40
|
-
def inspect
|
|
41
|
-
if description = self.description
|
|
42
|
-
"\#<#{self.name || "Context"} #{self.description}>"
|
|
43
|
-
else
|
|
44
|
-
self.name
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
27
|
# Add a child context or test to this context.
|
|
50
28
|
# @parameter child [Object] The child to add.
|
|
51
29
|
def add(child)
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# Copyright, 2025-2026, by Samuel Williams.
|
|
5
5
|
|
|
6
6
|
require "tmpdir"
|
|
7
|
+
require "fileutils"
|
|
7
8
|
|
|
8
9
|
module Sus
|
|
9
10
|
module Fixtures
|
|
@@ -12,10 +13,17 @@ module Sus
|
|
|
12
13
|
# Set up a temporary directory before the test and clean it up after.
|
|
13
14
|
# @yields {|&block| ...} The test block to execute.
|
|
14
15
|
def around(&block)
|
|
15
|
-
Dir.mktmpdir
|
|
16
|
+
root = Dir.mktmpdir
|
|
17
|
+
|
|
18
|
+
begin
|
|
16
19
|
@root = root
|
|
20
|
+
|
|
17
21
|
super(&block)
|
|
22
|
+
ensure
|
|
18
23
|
@root = nil
|
|
24
|
+
|
|
25
|
+
# Use forced removal so cleanup tolerates paths which were already removed by the test or an external process.
|
|
26
|
+
FileUtils.remove_entry(root, true)
|
|
19
27
|
end
|
|
20
28
|
end
|
|
21
29
|
|
|
@@ -24,4 +32,3 @@ module Sus
|
|
|
24
32
|
end
|
|
25
33
|
end
|
|
26
34
|
end
|
|
27
|
-
|
data/lib/sus/identity.rb
CHANGED
|
@@ -142,7 +142,7 @@ module Sus
|
|
|
142
142
|
end
|
|
143
143
|
else
|
|
144
144
|
# In theory this should be a bit faster:
|
|
145
|
-
each_caller_location do |location|
|
|
145
|
+
Thread.each_caller_location do |location|
|
|
146
146
|
if location.path == @path
|
|
147
147
|
return self.with_line(location.lineno)
|
|
148
148
|
end
|
|
@@ -154,16 +154,6 @@ module Sus
|
|
|
154
154
|
|
|
155
155
|
protected
|
|
156
156
|
|
|
157
|
-
if Thread.respond_to?(:each_caller_location)
|
|
158
|
-
def each_caller_location(&block)
|
|
159
|
-
Thread.each_caller_location(&block)
|
|
160
|
-
end
|
|
161
|
-
else
|
|
162
|
-
def each_caller_location(&block)
|
|
163
|
-
caller_locations(1).each(&block)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
157
|
def append_unique_key(key, unique = @unique)
|
|
168
158
|
if @parent
|
|
169
159
|
@parent.append_unique_key(key)
|
data/lib/sus/it.rb
CHANGED
|
@@ -107,17 +107,19 @@ module Sus
|
|
|
107
107
|
|
|
108
108
|
# Skip the test unless the Ruby version meets the minimum requirement.
|
|
109
109
|
# @parameter version [String] The minimum Ruby version required.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
# @parameter ruby_version [String] The Ruby version to check.
|
|
111
|
+
def skip_unless_minimum_ruby_version(version, ruby_version = RUBY_VERSION)
|
|
112
|
+
unless compare_ruby_version(ruby_version, version) >= 0
|
|
113
|
+
skip "Ruby #{version} is required, but running #{ruby_version}!"
|
|
113
114
|
end
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
# Skip the test if the Ruby version exceeds the maximum supported version.
|
|
117
118
|
# @parameter version [String] The maximum Ruby version supported.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
# @parameter ruby_version [String] The Ruby version to check.
|
|
120
|
+
def skip_if_maximum_ruby_version(version, ruby_version = RUBY_VERSION)
|
|
121
|
+
if compare_ruby_version(ruby_version, version) >= 0
|
|
122
|
+
skip "Ruby #{version} is not supported, but running #{ruby_version}!"
|
|
121
123
|
end
|
|
122
124
|
end
|
|
123
125
|
|
|
@@ -128,5 +130,23 @@ module Sus
|
|
|
128
130
|
skip "Ruby platform #{match} is not supported!"
|
|
129
131
|
end
|
|
130
132
|
end
|
|
133
|
+
|
|
134
|
+
private
|
|
135
|
+
|
|
136
|
+
def compare_ruby_version(left, right)
|
|
137
|
+
left_segments = left.split(".").map(&:to_i)
|
|
138
|
+
right_segments = right.split(".").map(&:to_i)
|
|
139
|
+
length = [left_segments.size, right_segments.size].max
|
|
140
|
+
|
|
141
|
+
length.times do |index|
|
|
142
|
+
left_segment = left_segments[index] || 0
|
|
143
|
+
right_segment = right_segments[index] || 0
|
|
144
|
+
|
|
145
|
+
return -1 if left_segment < right_segment
|
|
146
|
+
return 1 if left_segment > right_segment
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
return 0
|
|
150
|
+
end
|
|
131
151
|
end
|
|
132
152
|
end
|
data/lib/sus/mock.rb
CHANGED
|
@@ -90,8 +90,8 @@ module Sus
|
|
|
90
90
|
|
|
91
91
|
@interceptor.define_method(method) do |*arguments, **options, &block|
|
|
92
92
|
if execution_context == Thread.current
|
|
93
|
-
original = proc do |*arguments, **options|
|
|
94
|
-
super(*arguments, **options)
|
|
93
|
+
original = proc do |*arguments, **options, &block|
|
|
94
|
+
super(*arguments, **options, &block)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
hook.call(original, *arguments, **options, &block)
|
data/lib/sus/receive.rb
CHANGED
|
@@ -239,8 +239,7 @@ module Sus
|
|
|
239
239
|
# @parameter subject [Proc, nil] The block to check.
|
|
240
240
|
def call(assertions, subject)
|
|
241
241
|
assertions.nested(self) do |assertions|
|
|
242
|
-
|
|
243
|
-
Expect.new(assertions, subject).not.to(Be == nil)
|
|
242
|
+
Expect.new(assertions, subject).to(@predicate)
|
|
244
243
|
end
|
|
245
244
|
end
|
|
246
245
|
end
|
data/lib/sus/respond_to.rb
CHANGED
|
@@ -21,9 +21,9 @@ module Sus
|
|
|
21
21
|
parameters = @parameters.dup
|
|
22
22
|
|
|
23
23
|
assertions.nested(self) do |assertions|
|
|
24
|
-
expected_name = parameters.shift
|
|
25
|
-
|
|
26
24
|
subject.each do |type, name|
|
|
25
|
+
expected_name = parameters.shift
|
|
26
|
+
|
|
27
27
|
case type
|
|
28
28
|
when :req
|
|
29
29
|
assertions.assert(name == expected_name, "parameter #{expected_name} is required, but was #{name}")
|
data/lib/sus/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -33,6 +33,14 @@ Please see the [project documentation](https://socketry.github.io/sus/) for more
|
|
|
33
33
|
|
|
34
34
|
Please see the [project releases](https://socketry.github.io/sus/releases/index) for all releases.
|
|
35
35
|
|
|
36
|
+
### v0.37.2
|
|
37
|
+
|
|
38
|
+
- Make `Sus::Fixtures::TemporaryDirectoryContext` ignore temporary directory cleanup failures.
|
|
39
|
+
|
|
40
|
+
### v0.37.1
|
|
41
|
+
|
|
42
|
+
- Fixed `Sus::Mock#wrap` to forward blocks to the original method, and fixed `receive(...).with_block(...)` to use the supplied predicate.
|
|
43
|
+
|
|
36
44
|
### v0.37.0
|
|
37
45
|
|
|
38
46
|
- Long values in verbose (and failure) output are now truncated to a configurable length (default 100 characters), preventing huge objects from flooding the output. Set the `SUS_OUTPUT_VARIABLE_TRUNCATION_LIMIT` environment variable to change the limit, or `0` to disable truncation.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.37.2
|
|
4
|
+
|
|
5
|
+
- Make `Sus::Fixtures::TemporaryDirectoryContext` ignore temporary directory cleanup failures.
|
|
6
|
+
|
|
7
|
+
## v0.37.1
|
|
8
|
+
|
|
9
|
+
- Fixed `Sus::Mock#wrap` to forward blocks to the original method, and fixed `receive(...).with_block(...)` to use the supplied predicate.
|
|
10
|
+
|
|
3
11
|
## v0.37.0
|
|
4
12
|
|
|
5
13
|
- Long values in verbose (and failure) output are now truncated to a configurable length (default 100 characters), preventing huge objects from flooding the output. Set the `SUS_OUTPUT_VARIABLE_TRUNCATION_LIMIT` environment variable to change the limit, or `0` to disable truncation.
|
data.tar.gz.sig
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
2�:�R�=C9=��y�$�i[��j��L�b^r���s���<
|
|
1
|
+
F�a���@2R�)Y�R���g쮉Z�^�&,j(t��]��zN���upd��!`���,_��]�ܸ����O�,����n�r�� ��Dc�����cg�L�[�Ve��"%(駗���P,\����@�����Po�Z)��&��dM��W���
|
|
2
|
+
7�׃`Ơ����ۨ�cl���lӵZ�H�vV:��He�l���sM"C�imO�������X�������r;��N����<�����"�`�3��˵��y����eԭlH���o�������ۭzq���,�S�,��6��&U�~tH9�>bլ�ə��m��:��p���� N2h�9��x� �R��YX1�]��J�`��!y�<�;t�T3�>��!����U
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|