philiprehberger-assert 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -0
- data/lib/philiprehberger/assert/assertion.rb +4 -0
- data/lib/philiprehberger/assert/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e39e8f2c580c51b62aee03496bca3941ac2efe839618a379e5a50721e2e2e0f1
|
|
4
|
+
data.tar.gz: 1dd5e255316ff40587c86a795a098ca8d40aba63c3e8ba8505458b9a9455e3b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25bdfe4360a3d1619e7c0aeb7f7235c47b8cdac18c047ed14c6bbb5baad2b36ad546444f8e7a8b2c0eab814f2d6e3a101fbbec5472c4ed78dcdbb12f1f0456d9
|
|
7
|
+
data.tar.gz: 02f70ca6912c4ac85b05d19ed44dcb4c53eb9e89c15752933c46fc2197884df3a74f3089c9ee714a596b30e8db7eeb77d23e35dd60008d1a020bb3b199cb7f9a
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-04-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `satisfies(description = nil, &block)` matcher for custom block-based assertions
|
|
14
|
+
|
|
10
15
|
## [0.2.0] - 2026-04-04
|
|
11
16
|
|
|
12
17
|
### Added
|
data/README.md
CHANGED
|
@@ -53,6 +53,13 @@ Assert.that(status).one_of(:active, :inactive, :pending)
|
|
|
53
53
|
Assert.that(handler).responds_to(:call, :arity)
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
### Custom Block Assertions
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
Assert.that(age).satisfies('must be voting age') { |v| v >= 18 }
|
|
60
|
+
Assert.that(email).satisfies { |v| v.include?('@') && v.include?('.') }
|
|
61
|
+
```
|
|
62
|
+
|
|
56
63
|
### Custom Messages
|
|
57
64
|
|
|
58
65
|
```ruby
|
|
@@ -97,6 +104,7 @@ Philiprehberger::Assert.precondition(user.active?, 'user must be active')
|
|
|
97
104
|
| `.between(min, max)` | Assert value is between min and max (inclusive) |
|
|
98
105
|
| `.one_of(*values)` | Assert value is included in the list |
|
|
99
106
|
| `.responds_to(*methods)` | Assert value responds to all listed methods |
|
|
107
|
+
| `.satisfies(description = nil, &block)` | Assert block returns truthy for value |
|
|
100
108
|
|
|
101
109
|
## Development
|
|
102
110
|
|
|
@@ -68,6 +68,10 @@ module Philiprehberger
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
def satisfies(description = nil, &block)
|
|
72
|
+
check(block.call(@value), "Expected #{@value.inspect} to satisfy #{description || 'custom condition'}")
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
private
|
|
72
76
|
|
|
73
77
|
def check(condition, default_message)
|