sus 0.22.2 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c70a977a33735903d76e45646448e680ad8c296d5a78b82c8cb06d597f79764b
4
- data.tar.gz: 724ed6df638cc6871340b0f716f1a30f5c02952fb915889f31666c56f03d3c7d
3
+ metadata.gz: 7c2d41bca4906fd41229694de7d745d2801ab00eb528c4da69d7c8d7b3dfeb96
4
+ data.tar.gz: 9bcc82bf379b63ea46c8c15fcbc9528a391cc3cec60a960f2cc884e88ece4c20
5
5
  SHA512:
6
- metadata.gz: 74683ea93689e366705fa06bd54f179901fe6b6c275c8898c5e4def4efba00f27f6bc0d4ec1931546efadaa0478a47a1a19c16f6a8635f3859eee340a05d2383
7
- data.tar.gz: dc51defc2fd29cd488037fae3411ccddd93c58d9a124264ba03bb4369253aec2721ea4f3b62c863ff853a83d7a250aec6c22e3daa4d68baeb69d211b27c408b1
6
+ metadata.gz: 78f77fb2e30226a9c73714f46d79e3652fbd18826b54fef2a267c04eb31ecdb931372bc60a96f64711e5486e91ebc8b56a00fc292e554c2e7e3f3916d2a16037
7
+ data.tar.gz: 99626e222b997286b22a6a9ecf00960d86f5d991ee9b8f841720868b396234fa17319a31ede8990bdc381b398020927ac32ecc1769ce21c7fc9b78aa1586f456
checksums.yaml.gz.sig CHANGED
Binary file
@@ -192,16 +192,10 @@ module Sus
192
192
 
193
193
  if condition
194
194
  @passed << assert
195
-
196
- if !@orientation || @verbose
197
- @output.assert(condition, @orientation, message || "assertion passed", backtrace)
198
- end
195
+ @output.assert(condition, @orientation, message || "assertion passed", backtrace)
199
196
  else
200
197
  @failed << assert
201
-
202
- if @orientation || @verbose
203
- @output.assert(condition, @orientation, message || "assertion failed", backtrace)
204
- end
198
+ @output.assert(condition, @orientation, message || "assertion failed", backtrace)
205
199
  end
206
200
  end
207
201
 
data/lib/sus/be_within.rb CHANGED
@@ -16,7 +16,7 @@ module Sus
16
16
 
17
17
  def call(assertions, subject)
18
18
  assertions.nested(self) do |assertions|
19
- assertions.assert(@range.include?(subject), subject)
19
+ assertions.assert(@range.include?(subject))
20
20
  end
21
21
  end
22
22
  end
@@ -32,7 +32,9 @@ module Sus
32
32
  end
33
33
 
34
34
  def percent_of(value)
35
- of(value * Rational(@tolerance, 100))
35
+ tolerance = Rational(@tolerance, 100)
36
+
37
+ return Bounded.new(Range.new(value - value * tolerance, value + value * tolerance))
36
38
  end
37
39
 
38
40
  def print(output)
data/lib/sus/have.rb CHANGED
@@ -21,7 +21,9 @@ module Sus
21
21
  def call(assertions, subject)
22
22
  assertions.nested(self) do |assertions|
23
23
  assertions.assert(subject.key?(@name), "has key")
24
- @predicate&.call(assertions, subject[@name])
24
+ if @predicate
25
+ Expect.new(assertions, subject[@name]).to(@predicate)
26
+ end
25
27
  end
26
28
  end
27
29
  end
@@ -39,7 +41,9 @@ module Sus
39
41
  def call(assertions, subject)
40
42
  assertions.nested(self) do |assertions|
41
43
  assertions.assert(subject.respond_to?(@name), "has attribute")
42
- @predicate&.call(assertions, subject.send(@name))
44
+ if @predicate
45
+ Expect.new(assertions, subject.send(@name)).to(@predicate)
46
+ end
43
47
  end
44
48
  end
45
49
  end
@@ -16,9 +16,7 @@ module Sus
16
16
 
17
17
  def call(assertions, subject)
18
18
  assertions.nested(self) do |assertions|
19
- duration = measure(subject)
20
-
21
- @predicate.call(assertions, duration)
19
+ Expect.new(assertions, measure(subject)).to(@predicate)
22
20
  end
23
21
  end
24
22
 
@@ -15,7 +15,21 @@ module Sus
15
15
  def self.for(exception, identity = nil)
16
16
  # I've disabled the root filter here, because partial backtraces are not very useful.
17
17
  # We might want to do something to improve presentation of the backtrace based on the root instead.
18
- self.new(exception.backtrace_locations, identity&.path)
18
+ self.new(extract_stack(exception), identity&.path)
19
+ end
20
+
21
+ Location = Struct.new(:path, :lineno, :label)
22
+
23
+ def self.extract_stack(exception)
24
+ if stack = exception.backtrace_locations
25
+ return stack
26
+ elsif stack = exception.backtrace
27
+ return stack.map do |line|
28
+ Location.new(*line.split(":", 3))
29
+ end
30
+ else
31
+ []
32
+ end
19
33
  end
20
34
 
21
35
  def initialize(stack, root = nil, limit = nil)
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.22.2"
7
+ VERSION = "0.24.0"
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.22.2
4
+ version: 0.24.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: 2023-08-01 00:00:00.000000000 Z
41
+ date: 2023-11-30 00:00:00.000000000 Z
42
42
  dependencies: []
43
43
  description:
44
44
  email:
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- Cu �� C50czkP8{�Ba��jFs��T>)w�`:�4s��kgT~=)TB�M�/�>������VI�C��{;&�r9m����=TG�>K������x11s�2��{V���[_�&��RWs�oSw� G���A���<rBw������P<��$��c�H����^����p��c8T����c�9�Y=����Ӂ�Ǜ��{���% ��
2
- _k�4nC�\s$'_��Kd�A�����-�"��4��ݟ:�j�� z!+s����s�j�Ô��;c��#L�3����
1
+ !�˷w�,���K{���YE���;QE��dg�i��?qq�w�����!��{ |�)+����d엺�t�u6c2�<}������sbsm Y���2��);){ӾRy9ᨍZXG$�sv+lGP88X��I�N9�䷖�([mes����)�U��pL<� /�����{S�.����؅dS[��:؆$8��_�1��0
2
+