minitest-strict 1.0.0 → 1.0.1
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 +10 -0
- data/README.md +28 -0
- data/lib/minitest/strict/version.rb +1 -1
- data/lib/minitest/strict.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90ddd99c8cc1dc80b143781ccc85afc25955ffa31a208f4830662eeda3651675
|
|
4
|
+
data.tar.gz: 58edeab6ae51aff0ea36561977e014080eaf571155289286eb1748d59b5b4a9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 324e9e939b2d0d8d10d74b8717c72d8f9b9bed618444b38fea9f11bf124bceedd19e9c7b462e030d51a26e36261d31ccf576ea261bd8cd97c23fd68412db2c68
|
|
7
|
+
data.tar.gz: 901e6a061d0e4fca71352243896314df7268930f93bf95f5ea0e37dd71ea8c62cacb0cdbd19b66d865a67fb7b841be5071d341bf43f4c0fc33b902711f9a6cdb
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.1] - 2026-07-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `refute_match` no longer always fails on Minitest 6, which reimplemented it
|
|
13
|
+
via `refute_operator`. Since `=~` returns `nil` or an `Integer` — never
|
|
14
|
+
`false` — the strict `refute_operator` rejected every non-match.
|
|
15
|
+
minitest-strict now defines `refute_match` directly, restoring the standard
|
|
16
|
+
Minitest 5 behavior. ([#1](https://github.com/sferik/minitest-strict/issues/1))
|
|
17
|
+
|
|
8
18
|
## [1.0.0] - 2026-02-26
|
|
9
19
|
|
|
10
20
|
### Added
|
data/README.md
CHANGED
|
@@ -117,6 +117,13 @@ refute_predicate 0, :nonzero? # fail — returns nil, not false
|
|
|
117
117
|
|
|
118
118
|
### `assert_operator` / `refute_operator`
|
|
119
119
|
|
|
120
|
+
> [!WARNING]
|
|
121
|
+
> Operators like `=~` return non-boolean values (`nil` or an `Integer`), so
|
|
122
|
+
> they will always fail with minitest-strict's `assert_operator` and
|
|
123
|
+
> `refute_operator`. Assert on the actual return value instead: use
|
|
124
|
+
> `assert_match` / `refute_match`, or `assert_equal 2, x =~ y` to pin the
|
|
125
|
+
> match position, or `assert_nil x =~ y` for a non-match.
|
|
126
|
+
|
|
120
127
|
Requires operators to return exactly `true` or `false`.
|
|
121
128
|
|
|
122
129
|
```ruby
|
|
@@ -131,6 +138,27 @@ obj.define_singleton_method(:<=>) { |_| 1 }
|
|
|
131
138
|
assert_operator obj, :<=>, 2 # fail — returns 1, not true
|
|
132
139
|
```
|
|
133
140
|
|
|
141
|
+
### `refute_match`
|
|
142
|
+
|
|
143
|
+
> [!NOTE]
|
|
144
|
+
> This one is redefined for compatibility, not strictness. Minitest 6
|
|
145
|
+
> implements `refute_match` via `refute_operator`, but `=~` returns `nil` or
|
|
146
|
+
> an `Integer` — never `false` — so the strict `refute_operator` would reject
|
|
147
|
+
> every non-match. minitest-strict defines `refute_match` directly, preserving
|
|
148
|
+
> the standard behavior on both Minitest 5 and 6.
|
|
149
|
+
|
|
150
|
+
```ruby
|
|
151
|
+
refute_match(/nope/, "hello world") # pass
|
|
152
|
+
refute_match(/hello/, "hello world") # fail
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
> [!WARNING]
|
|
156
|
+
> Rails aliases `assert_no_match` to `refute_match` when
|
|
157
|
+
> `ActiveSupport::TestCase` loads, and `alias` copies the method body at that
|
|
158
|
+
> moment. On Minitest 6, require `minitest/strict` **before**
|
|
159
|
+
> `rails/test_help` so `assert_no_match` picks up the fixed implementation —
|
|
160
|
+
> or use `refute_match` directly.
|
|
161
|
+
|
|
134
162
|
### `assert_nil` / `refute_nil`
|
|
135
163
|
|
|
136
164
|
> [!NOTE]
|
data/lib/minitest/strict.rb
CHANGED
|
@@ -120,6 +120,21 @@ module Minitest
|
|
|
120
120
|
assert_equal false, o1.__send__(op, o2), msg
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
##
|
|
124
|
+
# Fails if +matcher+ matches +obj+. Redefined because Minitest 6
|
|
125
|
+
# implements this via refute_operator, but <tt>=~</tt> returns nil
|
|
126
|
+
# or an Integer -- never +false+ -- so the strict refute_operator
|
|
127
|
+
# above would fail even when +matcher+ does not match. There is no
|
|
128
|
+
# boolean contract to enforce here, so this restores the standard
|
|
129
|
+
# Minitest 5 behavior.
|
|
130
|
+
|
|
131
|
+
def refute_match matcher, obj, msg = nil
|
|
132
|
+
assert_respond_to matcher, :=~
|
|
133
|
+
msg = message(msg) { "Expected #{mu_pp matcher} to not match #{mu_pp obj}" }
|
|
134
|
+
matcher = Regexp.new Regexp.escape matcher if matcher.is_a?(String)
|
|
135
|
+
refute matcher =~ obj, msg
|
|
136
|
+
end
|
|
137
|
+
|
|
123
138
|
##
|
|
124
139
|
# Fails unless +obj+ is nil. Uses +equal?+ for identity check.
|
|
125
140
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: minitest-strict
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Berlin
|
|
@@ -42,7 +42,7 @@ files:
|
|
|
42
42
|
- README.md
|
|
43
43
|
- lib/minitest/strict.rb
|
|
44
44
|
- lib/minitest/strict/version.rb
|
|
45
|
-
homepage: https://github.
|
|
45
|
+
homepage: https://sferik.github.io/minitest-strict
|
|
46
46
|
licenses:
|
|
47
47
|
- MIT
|
|
48
48
|
metadata:
|
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
66
|
version: '0'
|
|
67
67
|
requirements: []
|
|
68
|
-
rubygems_version: 4.0.
|
|
68
|
+
rubygems_version: 4.0.17
|
|
69
69
|
specification_version: 4
|
|
70
70
|
summary: Strict assertions for Minitest
|
|
71
71
|
test_files: []
|