Backport upstream PR for Minitest 6.0.5 compatibility
This commit is contained in:
parent
2621b44181
commit
b1af410973
2 changed files with 88 additions and 0 deletions
82
flexmock-pr40-fix-minitest-assert_raises-usage.patch
Normal file
82
flexmock-pr40-fix-minitest-assert_raises-usage.patch
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
From bdde505f4c8fd8028f9da2f92505bba12e225635 Mon Sep 17 00:00:00 2001
|
||||
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
|
||||
Date: Wed, 22 Apr 2026 18:35:52 +0900
|
||||
Subject: [PATCH] fix: Use Minitest assert_raises correctly and handle error
|
||||
message
|
||||
|
||||
Actually
|
||||
https://github.com/minitest/minitest/blob/v6.0.5/lib/minitest/assertions.rb#L390
|
||||
says that `assert_raises` can take an optional "message" (i.e. string) to help
|
||||
explain failures, so not regex or so to test if assertion message matches it.
|
||||
|
||||
Up to Minitest 6.0.4, when passing regex for `assert_raises` it was simply
|
||||
ignored, ref:
|
||||
|
||||
https://github.com/minitest/minitest/issues/1068
|
||||
https://bugs.ruby-lang.org/issues/22007
|
||||
|
||||
Now Minitest 6.0.5 explicitly refuses this usage as:
|
||||
https://github.com/minitest/minitest/commit/6790f86f894637768a1f64cfe50959d2029b65ed
|
||||
|
||||
Closes #39 .
|
||||
---
|
||||
test/based_partials_test.rb | 3 ++-
|
||||
test/partial_mock_test.rb | 9 ++++++---
|
||||
2 files changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/test/based_partials_test.rb b/test/based_partials_test.rb
|
||||
index b9efcf5..fca2b61 100644
|
||||
--- a/test/based_partials_test.rb
|
||||
+++ b/test/based_partials_test.rb
|
||||
@@ -46,9 +46,10 @@ def test_based_partials_allow_stubbing_defined_methods
|
||||
|
||||
def test_based_partials_disallow_stubbing_undefined_methods
|
||||
dog = Dog.new
|
||||
- assert_raises(NoMethodError, /cannot stub.*wag.*explicitly/) do
|
||||
+ ex = assert_raises(NoMethodError) do
|
||||
flexmock(dog).should_receive(:wag => :mock_value)
|
||||
end
|
||||
+ assert_match(/Cannot stub.*wag.*explicitly/m, ex.message)
|
||||
end
|
||||
|
||||
def test_based_partials_allow_explicitly_stubbing_undefined_methods
|
||||
diff --git a/test/partial_mock_test.rb b/test/partial_mock_test.rb
|
||||
index beb8f8f..629e12e 100644
|
||||
--- a/test/partial_mock_test.rb
|
||||
+++ b/test/partial_mock_test.rb
|
||||
@@ -457,9 +457,10 @@ def test_partial_mocks_allow_stubbing_defined_methods_when_using_on
|
||||
def test_partial_mocks_disallow_stubbing_undefined_methods_when_using_on
|
||||
dog = Dog.new
|
||||
flexmock(dog, :on, Dog)
|
||||
- assert_raises(NoMethodError, /meow.*explicitly/) do
|
||||
+ ex = assert_raises(NoMethodError) do
|
||||
dog.should_receive(:meow).and_return(:something)
|
||||
end
|
||||
+ assert_match(/meow.*explicitly/m, ex.message)
|
||||
end
|
||||
|
||||
def test_partial_mocks_properly_detect_methods_defined_through_a_class_hierarchy
|
||||
@@ -497,9 +498,10 @@ def test_partial_mocks_will_not_require_explicitly_on_a_class_singleton_method_t
|
||||
def test_based_partial_mocks_require_explicitly_on_a_non_existing_method_of_a_class_singleton
|
||||
dog = Class.new
|
||||
FlexMock.partials_are_based = true
|
||||
- assert_raises(NoMethodError, /bark.*explicitly/) do
|
||||
+ ex = assert_raises(NoMethodError) do
|
||||
flexmock(dog).should_receive(:bark).and_return(:grrr)
|
||||
end
|
||||
+ assert_match(/bark.*explicitly/m, ex.message)
|
||||
ensure
|
||||
FlexMock.partials_are_based = false
|
||||
end
|
||||
@@ -511,9 +513,10 @@ def test_partial_mocks_require_explicitly_on_a_class_singleton_method_that_has_b
|
||||
FlexMock.partials_are_based = true
|
||||
flexmock(dog).should_receive(:bark).explicitly
|
||||
flexmock(chiwawa)
|
||||
- assert_raises(NoMethodError, /bark.*explicitly/) do
|
||||
+ ex = assert_raises(NoMethodError) do
|
||||
chiwawa.should_receive(:bark).and_return(:grrr)
|
||||
end
|
||||
+ assert_match(/bark.*explicitly/m, ex.message)
|
||||
ensure
|
||||
FlexMock.partials_are_based = false
|
||||
end
|
||||
|
|
@ -16,6 +16,10 @@ Patch0: flexmock-pr38-3.0.2-testsuite-ruby34-formatting.patch
|
|||
# https://github.com/doudou/flexmock/pull/38/changes/ead3616ca6af80144b1f884c2eb9d0fbf9e09dbc
|
||||
# Remove warnings for string literal being frozen in the future
|
||||
Patch1: flexmock-pr38-3.0.2-ruby34-string-literal-frozen.patch
|
||||
# https://github.com/doudou/flexmock/pull/40
|
||||
# Fix assert_raises usage with Minitest 6.0.5
|
||||
Patch2: flexmock-pr40-fix-minitest-assert_raises-usage.patch
|
||||
|
||||
|
||||
Requires: ruby(release)
|
||||
BuildRequires: ruby(release)
|
||||
|
|
@ -45,6 +49,7 @@ mv flexmock/test .
|
|||
|
||||
%patch -P0 -p1
|
||||
%patch -P1 -p1
|
||||
%patch -P2 -p1
|
||||
|
||||
find . -name \*.rb | xargs sed -i -e '\@/usr/bin/env@d'
|
||||
find . -name \*.gem -or -name \*.rb -or -name \*.rdoc | xargs chmod 0644
|
||||
|
|
@ -105,6 +110,7 @@ popd
|
|||
%changelog
|
||||
* Wed Apr 22 2026 Mamoru TASAKA <mtasaka@fedoraproject.org> - 3.0.2-3
|
||||
- Use upstream PR for patches
|
||||
- Backport upstream PR for Minitest 6.0.5 compatibility
|
||||
|
||||
* Sat Jan 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.2-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue