sus 0.10.3 → 0.10.4
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 +4 -0
- data/lib/sus/expect.rb +4 -0
- data/lib/sus/have_attributes.rb +41 -0
- data/lib/sus/it.rb +7 -2
- data/lib/sus/output/backtrace.rb +3 -1
- data/lib/sus/raise_exception.rb +15 -3
- data/lib/sus/version.rb +1 -1
- data/lib/sus.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbfd2216a9188a212a020c1e4780bc01e2d7b1246bf2f9475d28ad7e4e939f31
|
4
|
+
data.tar.gz: 4929af7ca54b12e5e5cf460a097a507c782c64a5eb9265e425df12ed71e5c1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f246c6a57ec8c2ac0bf995e7e7194e1aa2b526f858fc9efb6942b7769b7fe801b7c8095e06c4f5127d71669510813c00185d831cf983624cf2b6ad1776fc2d0
|
7
|
+
data.tar.gz: 279b9ec5642a6a3a4af069524c0944ff08d0d101066189054ac00ebacd215886a0f84b23dd2a6ae07ad0c65bc6c646bcd6374298910b913d9a9b152259aa64de
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sus/be.rb
CHANGED
data/lib/sus/expect.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2021-2022, by Samuel Williams.
|
5
|
+
|
6
|
+
module Sus
|
7
|
+
class HaveAttributes
|
8
|
+
def initialize(attributes)
|
9
|
+
@attributes = attributes
|
10
|
+
end
|
11
|
+
|
12
|
+
def print(output)
|
13
|
+
first = true
|
14
|
+
output.write("have attributes {")
|
15
|
+
@attributes.each do |key, predicate|
|
16
|
+
if first
|
17
|
+
first = false
|
18
|
+
else
|
19
|
+
output.write(", ")
|
20
|
+
end
|
21
|
+
|
22
|
+
output.write(:variable, key.to_s, :reset, " ", predicate, :reset)
|
23
|
+
end
|
24
|
+
output.write("}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def call(assertions, subject)
|
28
|
+
assertions.nested(self) do |assertions|
|
29
|
+
@attributes.each do |key, predicate|
|
30
|
+
predicate.call(assertions, subject.public_send(key))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Base
|
37
|
+
def have_attributes(...)
|
38
|
+
HaveAttributes.new(...)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/sus/it.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative 'context'
|
|
7
7
|
|
8
8
|
module Sus
|
9
9
|
module It
|
10
|
-
def self.build(parent, description, &block)
|
10
|
+
def self.build(parent, description = nil, &block)
|
11
11
|
base = Class.new(parent)
|
12
12
|
base.extend(It)
|
13
13
|
base.description = description
|
@@ -26,7 +26,12 @@ module Sus
|
|
26
26
|
|
27
27
|
def print(output)
|
28
28
|
self.superclass.print(output)
|
29
|
-
|
29
|
+
|
30
|
+
if description = self.description
|
31
|
+
output.write(" it ", :it, description, :reset, " ", :identity, self.identity.to_s, :reset)
|
32
|
+
else
|
33
|
+
output.write(" and ", :identity, self.identity.to_s, :reset)
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
def call(assertions)
|
data/lib/sus/output/backtrace.rb
CHANGED
@@ -13,7 +13,9 @@ module Sus
|
|
13
13
|
end
|
14
14
|
|
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
|
+
# 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)
|
17
19
|
end
|
18
20
|
|
19
21
|
def initialize(stack, root = nil, limit = nil)
|
data/lib/sus/raise_exception.rb
CHANGED
@@ -8,6 +8,12 @@ module Sus
|
|
8
8
|
def initialize(exception_class = nil, message: nil)
|
9
9
|
@exception_class = exception_class
|
10
10
|
@message = message
|
11
|
+
@predicate = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def and(predicate)
|
15
|
+
@predicate = predicate
|
16
|
+
return self
|
11
17
|
end
|
12
18
|
|
13
19
|
def call(assertions, subject)
|
@@ -16,14 +22,16 @@ module Sus
|
|
16
22
|
subject.call
|
17
23
|
|
18
24
|
# Didn't throw any exception, so the expectation failed:
|
19
|
-
assertions.assert(false,
|
25
|
+
assertions.assert(false, "raised")
|
20
26
|
rescue @exception_class => exception
|
21
27
|
# Did it have the right message?
|
22
28
|
if @message
|
23
|
-
assertions.assert(@message === exception.message)
|
29
|
+
assertions.assert(@message === exception.message, "raised with message")
|
24
30
|
else
|
25
|
-
assertions.assert(true,
|
31
|
+
assertions.assert(true, "raised")
|
26
32
|
end
|
33
|
+
|
34
|
+
@predicate&.call(assertions, exception)
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
@@ -38,6 +46,10 @@ module Sus
|
|
38
46
|
if @message
|
39
47
|
output.write(" with message ", :variable, @message, :reset)
|
40
48
|
end
|
49
|
+
|
50
|
+
if @predicate
|
51
|
+
output.write(" and ", @predicate)
|
52
|
+
end
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
data/lib/sus/version.rb
CHANGED
data/lib/sus.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.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2022-08-
|
40
|
+
date: 2022-08-26 00:00:00.000000000 Z
|
41
41
|
dependencies: []
|
42
42
|
description:
|
43
43
|
email:
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/sus/file.rb
|
63
63
|
- lib/sus/filter.rb
|
64
64
|
- lib/sus/fixtures.rb
|
65
|
+
- lib/sus/have_attributes.rb
|
65
66
|
- lib/sus/have_duration.rb
|
66
67
|
- lib/sus/identity.rb
|
67
68
|
- lib/sus/include_context.rb
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
��J��X^�v�9�p���?^[�<~b�E��>��$njh���h��V��#ux��V�P�Af|a�DV}��s/��#��dA�7-�6U�1��T;a��f��������3��h�TT��W��:���M �=����̃��
|
2
|
+
�nA�%��%����w������Q�6\�6��t㳉9I۾�d��2Uܠ��d{ ���,\_�t��]A�H��'E�?A���+?���5�e.p!%��z��
|