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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7f3cff1adfd1e6a69afec2832299ca911bf2732cb3c205c9c116edfaf094eb
4
- data.tar.gz: 8f45b484e5c08cd7c25498c028ff3f00540ef5b494561adbe964917fb2ebff87
3
+ metadata.gz: 90ddd99c8cc1dc80b143781ccc85afc25955ffa31a208f4830662eeda3651675
4
+ data.tar.gz: 58edeab6ae51aff0ea36561977e014080eaf571155289286eb1748d59b5b4a9c
5
5
  SHA512:
6
- metadata.gz: 2e7508a3ff72d562ca069ea2fa8a5b9330ff6066121beb8f4162849673cac097dbb2cceba10b8a03884a90285f11924846763bd834c1b56029bf87240e76544e
7
- data.tar.gz: bef6939ad19d6ecfea699367bbfd51f69e9a0fee664927f14ff254d0efe349e0403443c5c34804d290810fbe7974c687007958e547ae646c40bb590c038fa8bd
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]
@@ -3,6 +3,6 @@ module Minitest # :nodoc:
3
3
  # Version information for minitest-strict.
4
4
  module Strict
5
5
  # Current version of minitest-strict.
6
- VERSION = "1.0.0".freeze
6
+ VERSION = "1.0.1".freeze
7
7
  end
8
8
  end
@@ -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.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.com/sferik/minitest-strict
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.6
68
+ rubygems_version: 4.0.17
69
69
  specification_version: 4
70
70
  summary: Strict assertions for Minitest
71
71
  test_files: []