sus 0.10.4 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sus/be.rb +3 -1
- data/lib/sus/have.rb +103 -0
- data/lib/sus/version.rb +1 -1
- data/lib/sus.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
- data/lib/sus/have_attributes.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e40571705fc5474aff2158cee00b9fd9b80778fa9d5e7caa30da9d039095368
|
4
|
+
data.tar.gz: 94cb197a3d237636360f5e62c1b5095352fb2956c7a4a01c49388d4dceab065d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cda6d03170da4badb665d704afe42f02f80f162f51891dad475c9a6ad7539c4b76a315f655293a686ccf24338c4d7128722cabb30e3671018b20ca0959c3373
|
7
|
+
data.tar.gz: e4a0f447efe11fcc9a7417277faf55100903b711703a363532f28dedebed0b6d3cb0b13bc6675a8ac1b0c5d8eaa21566cbf305ab9b90cea05c9f77d05d2902c1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sus/be.rb
CHANGED
data/lib/sus/have.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2022, by Samuel Williams.
|
5
|
+
|
6
|
+
module Sus
|
7
|
+
module Have
|
8
|
+
class Composite
|
9
|
+
def initialize(predicates)
|
10
|
+
@predicates = predicates
|
11
|
+
end
|
12
|
+
|
13
|
+
def print(output)
|
14
|
+
first = true
|
15
|
+
output.write("have {")
|
16
|
+
@predicates.each do |predicate|
|
17
|
+
if first
|
18
|
+
first = false
|
19
|
+
else
|
20
|
+
output.write(", ")
|
21
|
+
end
|
22
|
+
|
23
|
+
output.write(predicate)
|
24
|
+
end
|
25
|
+
output.write("}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def call(assertions, subject)
|
29
|
+
assertions.nested(self) do |assertions|
|
30
|
+
@predicates.each do |predicate|
|
31
|
+
predicate.call(assertions, subject)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Key
|
38
|
+
def initialize(name, predicate = nil)
|
39
|
+
@name = name
|
40
|
+
@predicate = predicate
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(output)
|
44
|
+
output.write("key ", :variable, @name.inspect, :reset, " ", @predicate, :reset)
|
45
|
+
end
|
46
|
+
|
47
|
+
def call(assertions, subject)
|
48
|
+
assertions.nested(self) do |assertions|
|
49
|
+
assertions.assert(subject.key?(@name), "has key")
|
50
|
+
@predicate&.call(assertions, subject[@name])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Attribute
|
56
|
+
def initialize(name, predicate)
|
57
|
+
@name = name
|
58
|
+
@predicate = predicate
|
59
|
+
end
|
60
|
+
|
61
|
+
def print(output)
|
62
|
+
output.write("attribute ", :variable, @name.to_s, :reset, " ", @predicate, :reset)
|
63
|
+
end
|
64
|
+
|
65
|
+
def call(assertions, subject)
|
66
|
+
assertions.nested(self) do |assertions|
|
67
|
+
assertions.assert(subject.respond_to?(@name), "has attribute")
|
68
|
+
@predicate&.call(assertions, subject.send(@name))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Base
|
75
|
+
def have(*predicates)
|
76
|
+
Have::Composite.new(predicates)
|
77
|
+
end
|
78
|
+
|
79
|
+
def have_keys(*keys)
|
80
|
+
predicates = []
|
81
|
+
|
82
|
+
keys.each do |key|
|
83
|
+
if key.is_a?(Hash)
|
84
|
+
key.each do |key, predicate|
|
85
|
+
predicates << Have::Key.new(key, predicate)
|
86
|
+
end
|
87
|
+
else
|
88
|
+
predicates << Have::Key.new(key)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Have::Composite.new(predicates)
|
93
|
+
end
|
94
|
+
|
95
|
+
def have_attributes(**attributes)
|
96
|
+
predicates = attributes.map do |key, value|
|
97
|
+
Have::Attribute.new(key, value)
|
98
|
+
end
|
99
|
+
|
100
|
+
Have::Composite.new(predicates)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
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.
|
4
|
+
version: 0.11.0
|
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-27 00:00:00.000000000 Z
|
41
41
|
dependencies: []
|
42
42
|
description:
|
43
43
|
email:
|
@@ -62,7 +62,7 @@ files:
|
|
62
62
|
- lib/sus/file.rb
|
63
63
|
- lib/sus/filter.rb
|
64
64
|
- lib/sus/fixtures.rb
|
65
|
-
- lib/sus/
|
65
|
+
- lib/sus/have.rb
|
66
66
|
- lib/sus/have_duration.rb
|
67
67
|
- lib/sus/identity.rb
|
68
68
|
- lib/sus/include_context.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/sus/have_attributes.rb
DELETED
@@ -1,41 +0,0 @@
|
|
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
|