philiprehberger-assert 0.2.0 → 0.4.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: 744aa1559a905d80e4270e49c7cd34c8f7297da87e564c9fc72cc5eb6657c7ef
4
- data.tar.gz: a093d5dc977862e825be43d59c59d5db82feaaaf94737a559b29100a1f806d19
3
+ metadata.gz: f5fea50ef7ac475426e9456b67e82f2be344f3b97fccba75f2e0d1fe944c1ae7
4
+ data.tar.gz: 5fd7d6aca18f9c06d4ace4a050483b433f014203252d2cd7a0b8fc4c8fdbf5a4
5
5
  SHA512:
6
- metadata.gz: e869364de1ffbd2203b2980e6093394748c35eeaa3ba1feb72849131365ac604bab9c9003bf2cde58ccc8c621c4a0911c5c9938e5d3699fc3e85a2a525c78c20
7
- data.tar.gz: 75d8d8e5a48c0ecd08477c6adb7cb47061d679a77fa0fcc50e3fc522746b2c9fd795eee3b7f651e95952384fa2f6ff790d81fdc8ff9d7d1439a7bcb53392db26
6
+ metadata.gz: 8ef0576d1e93ec43284b49a11668e1d3fc8412576ab96919a0fbc997c282c1626be2ba91f0fa6118f6b1f7ef6ca0ec1a467402d79113e476914d667d778355a0
7
+ data.tar.gz: 69aa855412b4409cea2b6071ab560919acee192daa546a4b5bbd18cf2d5a7938e3751ebd947a56dbaf0510f9780525e9791058cf970177799c3112ffa6ecfa6f
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2026-04-15
11
+
12
+ ### Added
13
+ - `starts_with(prefix)` matcher for string prefix assertions
14
+ - `ends_with(suffix)` matcher for string suffix assertions
15
+
16
+ ## [0.3.0] - 2026-04-04
17
+
18
+ ### Added
19
+ - `satisfies(description = nil, &block)` matcher for custom block-based assertions
20
+
10
21
  ## [0.2.0] - 2026-04-04
11
22
 
12
23
  ### Added
data/README.md CHANGED
@@ -45,6 +45,13 @@ Philiprehberger::Assert.that(config).includes_key(:host)
45
45
  Philiprehberger::Assert.that(items).not_empty
46
46
  ```
47
47
 
48
+ ### String Prefix and Suffix
49
+
50
+ ```ruby
51
+ Assert.that('hello world').starts_with('hello')
52
+ Assert.that('hello world').ends_with('world')
53
+ ```
54
+
48
55
  ### Range and Membership
49
56
 
50
57
  ```ruby
@@ -53,6 +60,13 @@ Assert.that(status).one_of(:active, :inactive, :pending)
53
60
  Assert.that(handler).responds_to(:call, :arity)
54
61
  ```
55
62
 
63
+ ### Custom Block Assertions
64
+
65
+ ```ruby
66
+ Assert.that(age).satisfies('must be voting age') { |v| v >= 18 }
67
+ Assert.that(email).satisfies { |v| v.include?('@') && v.include?('.') }
68
+ ```
69
+
56
70
  ### Custom Messages
57
71
 
58
72
  ```ruby
@@ -91,12 +105,15 @@ Philiprehberger::Assert.precondition(user.active?, 'user must be active')
91
105
  | `Assertion#gt(num)` | Assert value > num |
92
106
  | `Assertion#lt(num)` | Assert value < num |
93
107
  | `Assertion#matches(pattern)` | Assert value matches regex pattern |
108
+ | `Assertion#starts_with(prefix)` | Assert string value starts with prefix |
109
+ | `Assertion#ends_with(suffix)` | Assert string value ends with suffix |
94
110
  | `Assertion#not_blank` | Assert value is not nil or blank |
95
111
  | `Assertion#not_empty` | Assert value is not empty |
96
112
  | `Assertion#includes_key(key)` | Assert hash includes key |
97
113
  | `.between(min, max)` | Assert value is between min and max (inclusive) |
98
114
  | `.one_of(*values)` | Assert value is included in the list |
99
115
  | `.responds_to(*methods)` | Assert value responds to all listed methods |
116
+ | `.satisfies(description = nil, &block)` | Assert block returns truthy for value |
100
117
 
101
118
  ## Development
102
119
 
@@ -34,6 +34,14 @@ module Philiprehberger
34
34
  check(pattern.match?(@value.to_s), "Expected #{@value.inspect} to match #{pattern.inspect}")
35
35
  end
36
36
 
37
+ def starts_with(prefix)
38
+ check(@value.start_with?(prefix), "expected to start with #{prefix.inspect}")
39
+ end
40
+
41
+ def ends_with(suffix)
42
+ check(@value.end_with?(suffix), "expected to end with #{suffix.inspect}")
43
+ end
44
+
37
45
  def not_blank
38
46
  check(!@value.nil? && !@value.to_s.strip.empty?, 'Expected value to not be blank')
39
47
  end
@@ -68,6 +76,10 @@ module Philiprehberger
68
76
  end
69
77
  end
70
78
 
79
+ def satisfies(description = nil, &block)
80
+ check(block.call(@value), "Expected #{@value.inspect} to satisfy #{description || 'custom condition'}")
81
+ end
82
+
71
83
  private
72
84
 
73
85
  def check(condition, default_message)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module Assert
5
- VERSION = '0.2.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
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.2.0
4
+ version: 0.4.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-04-05 00:00:00.000000000 Z
11
+ date: 2026-04-15 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.