sus 0.27.0 → 0.29.0

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: 15dd552861dc2a448ac4717e95092d21b76e9f09e50492269a898c8d7db464e3
4
- data.tar.gz: 47e84419dadb77bfa29e82b8383f7ae90b18d8a170cdd4136e2ef75f3f5afb38
3
+ metadata.gz: 6ec538e7cbf293f075dd262e212e705edc33d457e4791458d5d75a3179cfca2f
4
+ data.tar.gz: 6193fb56afb1124b67d5ecf44f646f71a97919c8924c7d6dbc586ed4e566c843
5
5
  SHA512:
6
- metadata.gz: aa482cd7ea24f6b6f5b32f59582403171ecf8695f490edc0a1149366566d05424e8199d813f4ff0cbd5ef6b2abd327013f35b112a84c905bba62ded1bee9e478
7
- data.tar.gz: 3bf33b5fdcf42584ba46e360b9a83367b2f09ebc15a6b23497f2485fcd105ea5c354e10e4a15b084624aff8af2a506305771e9edd4754cc7b7e700a99fd50683
6
+ metadata.gz: 8b537a93be3bc1f008cee17659df931a04f9f1bcbc219d2813543ba4372c479d9f56b6de5d9aae1fca4179beab095450789fd7f046e89d1d6509921cb2eafab1
7
+ data.tar.gz: a4c27583848df35d4c40c95c73f128d7521b05856b14c50b80f094637d4f850ea44e32f0fd917f40a48603a1e6ede1bf83772a0bdeb4f5918da51d9fb8a1ac0d
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sus/be.rb CHANGED
@@ -5,10 +5,96 @@
5
5
 
6
6
  module Sus
7
7
  class Be
8
+ class And
9
+ def initialize(predicates)
10
+ @predicates = predicates
11
+ end
12
+
13
+ def print(output)
14
+ @predicates.each_with_index do |predicate, index|
15
+ if index > 0
16
+ output.write(" and ", :reset)
17
+ end
18
+
19
+ predicate.print(output)
20
+ end
21
+ end
22
+
23
+ def call(assertions, subject)
24
+ @predicates.each do |predicate|
25
+ predicate.call(assertions, subject)
26
+ end
27
+ end
28
+
29
+ def &(other)
30
+ And.new(@predicates + [other])
31
+ end
32
+
33
+ def |(other)
34
+ Or.new(self, other)
35
+ end
36
+ end
37
+
38
+ class Or
39
+ def initialize(predicates)
40
+ @predicates = predicates
41
+ end
42
+
43
+ def print(output)
44
+ @predicates.each_with_index do |predicate, index|
45
+ if index > 0
46
+ output.write(" or ", :reset)
47
+ end
48
+
49
+ predicate.print(output)
50
+ end
51
+ end
52
+
53
+ def call(assertions, subject)
54
+ assertions.nested(self) do |assertions|
55
+ @predicates.each do |predicate|
56
+ predicate.call(assertions, subject)
57
+ end
58
+
59
+ if assertions.passed.any?
60
+ # At least one passed, so we don't care about failures:
61
+ assertions.failed.clear
62
+ else
63
+ # Nothing passed, so we failed:
64
+ assertions.assert(false, "could not find any matching predicate")
65
+ end
66
+ end
67
+ end
68
+
69
+ def &(other)
70
+ And.new(self, other)
71
+ end
72
+
73
+ def |(other)
74
+ Or.new(@predicates + [other])
75
+ end
76
+ end
77
+
8
78
  def initialize(*arguments)
9
79
  @arguments = arguments
10
80
  end
11
81
 
82
+ def |(other)
83
+ Or.new([self, other])
84
+ end
85
+
86
+ def or(*others)
87
+ Or.new([self, *others])
88
+ end
89
+
90
+ def &(other)
91
+ And.new([self, other])
92
+ end
93
+
94
+ def and(*others)
95
+ And.new([self, *others])
96
+ end
97
+
12
98
  def print(output)
13
99
  operation, *arguments = *@arguments
14
100
 
data/lib/sus/have.rb CHANGED
@@ -58,10 +58,14 @@ module Sus
58
58
  end
59
59
 
60
60
  def call(assertions, subject)
61
- subject.each_with_index do |value, index|
61
+ index = 0
62
+
63
+ subject.each do |value|
62
64
  assertions.nested("[#{index}] = #{value.inspect}") do |assertions|
63
65
  @predicate&.call(assertions, value)
64
66
  end
67
+
68
+ index += 1
65
69
  end
66
70
  end
67
71
  end
data/lib/sus/mock.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2024, by Samuel Williams.
5
5
 
6
6
  require_relative 'expect'
7
7
 
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2024, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.27.0"
7
+ VERSION = "0.29.0"
8
8
  end
data/readme.md CHANGED
@@ -12,7 +12,7 @@ Non-features:
12
12
  - Flexibility at the expense of performance.
13
13
  - Backwards compatibility.
14
14
 
15
- [![Development Status](https://github.com/ioquatix/sus/workflows/Test/badge.svg)](https://github.com/ioquatix/sus/actions?workflow=Test)
15
+ [![Development Status](https://github.com/sus-rb/sus/workflows/Test/badge.svg)](https://github.com/sus-rb/sus/actions?workflow=Test)
16
16
 
17
17
  ## Ideas
18
18
 
@@ -48,8 +48,8 @@ We welcome contributions to this project.
48
48
 
49
49
  ### Developer Certificate of Origin
50
50
 
51
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
51
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
52
52
 
53
- ### Contributor Covenant
53
+ ### Community Guidelines
54
54
 
55
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
55
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
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.27.0
4
+ version: 0.29.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: 2024-06-23 00:00:00.000000000 Z
41
+ date: 2024-07-17 00:00:00.000000000 Z
42
42
  dependencies: []
43
43
  description:
44
44
  email:
@@ -101,13 +101,13 @@ files:
101
101
  - lib/sus/with.rb
102
102
  - license.md
103
103
  - readme.md
104
- homepage: https://github.com/ioquatix/sus
104
+ homepage: https://github.com/sus-rb/sus
105
105
  licenses:
106
106
  - MIT
107
107
  metadata:
108
- documentation_uri: https://ioquatix.github.io/sus/
108
+ documentation_uri: https://sus-rb.github.io/sus/
109
109
  funding_uri: https://github.com/sponsors/ioquatix/
110
- source_code_uri: https://github.com/ioquatix/sus.git
110
+ source_code_uri: https://github.com/sus-rb/sus.git
111
111
  post_install_message:
112
112
  rdoc_options: []
113
113
  require_paths:
metadata.gz.sig CHANGED
Binary file