philiprehberger-assert 0.1.10 → 0.2.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 +14 -0
- data/README.md +11 -0
- data/lib/philiprehberger/assert/assertion.rb +22 -0
- data/lib/philiprehberger/assert/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 744aa1559a905d80e4270e49c7cd34c8f7297da87e564c9fc72cc5eb6657c7ef
|
|
4
|
+
data.tar.gz: a093d5dc977862e825be43d59c59d5db82feaaaf94737a559b29100a1f806d19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e869364de1ffbd2203b2980e6093394748c35eeaa3ba1feb72849131365ac604bab9c9003bf2cde58ccc8c621c4a0911c5c9938e5d3699fc3e85a2a525c78c20
|
|
7
|
+
data.tar.gz: 75d8d8e5a48c0ecd08477c6adb7cb47061d679a77fa0fcc50e3fc522746b2c9fd795eee3b7f651e95952384fa2f6ff790d81fdc8ff9d7d1439a7bcb53392db26
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-04-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `between(min, max)` matcher for range assertions
|
|
14
|
+
- `one_of(*values)` matcher for membership assertions
|
|
15
|
+
- `responds_to(*methods)` matcher for interface assertions
|
|
16
|
+
- GitHub issue template gem version field
|
|
17
|
+
- Feature request "Alternatives considered" field
|
|
18
|
+
|
|
19
|
+
## [0.1.11] - 2026-03-31
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- Add GitHub issue templates, dependabot config, and PR template
|
|
23
|
+
|
|
10
24
|
## [0.1.10] - 2026-03-31
|
|
11
25
|
|
|
12
26
|
### Changed
|
data/README.md
CHANGED
|
@@ -45,6 +45,14 @@ Philiprehberger::Assert.that(config).includes_key(:host)
|
|
|
45
45
|
Philiprehberger::Assert.that(items).not_empty
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
### Range and Membership
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
Assert.that(age).between(0, 150)
|
|
52
|
+
Assert.that(status).one_of(:active, :inactive, :pending)
|
|
53
|
+
Assert.that(handler).responds_to(:call, :arity)
|
|
54
|
+
```
|
|
55
|
+
|
|
48
56
|
### Custom Messages
|
|
49
57
|
|
|
50
58
|
```ruby
|
|
@@ -86,6 +94,9 @@ Philiprehberger::Assert.precondition(user.active?, 'user must be active')
|
|
|
86
94
|
| `Assertion#not_blank` | Assert value is not nil or blank |
|
|
87
95
|
| `Assertion#not_empty` | Assert value is not empty |
|
|
88
96
|
| `Assertion#includes_key(key)` | Assert hash includes key |
|
|
97
|
+
| `.between(min, max)` | Assert value is between min and max (inclusive) |
|
|
98
|
+
| `.one_of(*values)` | Assert value is included in the list |
|
|
99
|
+
| `.responds_to(*methods)` | Assert value responds to all listed methods |
|
|
89
100
|
|
|
90
101
|
## Development
|
|
91
102
|
|
|
@@ -46,6 +46,28 @@ module Philiprehberger
|
|
|
46
46
|
check(@value.respond_to?(:key?) && @value.key?(key), "Expected #{@value.inspect} to include key #{key.inspect}")
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
def between(min, max)
|
|
50
|
+
check(@value.between?(min, max), "Expected #{@value.inspect} to be between #{min} and #{max}")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def one_of(*values)
|
|
54
|
+
check(values.include?(@value), "Expected #{@value.inspect} to be one of #{values.inspect}")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def responds_to(*methods)
|
|
58
|
+
missing = methods.reject { |m| @value.respond_to?(m) }
|
|
59
|
+
if missing.empty?
|
|
60
|
+
self
|
|
61
|
+
else
|
|
62
|
+
msg = @message || "Expected #{@value.inspect} to respond to #{missing.join(', ')}"
|
|
63
|
+
raise AssertionError, msg unless @failures
|
|
64
|
+
|
|
65
|
+
@failures << msg
|
|
66
|
+
self
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
49
71
|
private
|
|
50
72
|
|
|
51
73
|
def check(condition, default_message)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-assert
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A lightweight runtime assertion library for Ruby with chainable matchers,
|
|
14
14
|
soft assertions, and Design by Contract preconditions.
|
|
@@ -25,11 +25,11 @@ files:
|
|
|
25
25
|
- lib/philiprehberger/assert/assertion.rb
|
|
26
26
|
- lib/philiprehberger/assert/errors.rb
|
|
27
27
|
- lib/philiprehberger/assert/version.rb
|
|
28
|
-
homepage: https://
|
|
28
|
+
homepage: https://philiprehberger.com/open-source-packages/ruby/philiprehberger-assert
|
|
29
29
|
licenses:
|
|
30
30
|
- MIT
|
|
31
31
|
metadata:
|
|
32
|
-
homepage_uri: https://
|
|
32
|
+
homepage_uri: https://philiprehberger.com/open-source-packages/ruby/philiprehberger-assert
|
|
33
33
|
source_code_uri: https://github.com/philiprehberger/rb-assert
|
|
34
34
|
changelog_uri: https://github.com/philiprehberger/rb-assert/blob/main/CHANGELOG.md
|
|
35
35
|
bug_tracker_uri: https://github.com/philiprehberger/rb-assert/issues
|