!4 [sync] PR-2: fix build error by upgrading to ruby3

From: @openeuler-sync-bot 
Reviewed-by: @shinwell_hu 
Signed-off-by: @shinwell_hu
This commit is contained in:
openeuler-ci-bot 2022-03-24 12:27:32 +00:00 committed by Gitee
commit cd9189e62f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 63 additions and 6 deletions

View File

@ -0,0 +1,15 @@
diff -urp '--exclude=*~' flexmock-2.3.6/lib.orig/flexmock/composite_expectation.rb flexmock-2.3.6/lib/flexmock/composite_expectation.rb
--- flexmock-2.3.6/lib.orig/flexmock/composite_expectation.rb 2021-01-24 01:35:33.614853539 +0900
+++ flexmock-2.3.6/lib/flexmock/composite_expectation.rb 2021-01-24 02:27:58.007313654 +0900
@@ -16,9 +16,9 @@ class FlexMock
end
# Apply the constraint method to all expectations in the composite.
- def method_missing(sym, *args, &block)
+ def method_missing(sym, *args, **keywords, &block)
@expectations.each do |expectation|
- expectation.send(sym, *args, &block)
+ expectation.send(sym, *args, **keywords, &block)
end
self
end

View File

@ -0,0 +1,11 @@
--- flexmock-2.3.6/test/test_helper.rb.ruby3 2021-01-24 00:41:42.121385766 +0900
+++ flexmock-2.3.6/test/test_helper.rb 2021-01-24 00:44:25.866236105 +0900
@@ -50,7 +50,7 @@
# added.
def assert_mock_failure(klass, options={}, &block)
ex = assert_failure(klass, options, &block)
- file = eval("__FILE__", block.binding)
+ file = block.binding.source_location.first
assert_matching_line(ex, file, options)
end

View File

@ -0,0 +1,12 @@
--- flexmock-2.3.6/test/partial_mock_test.rb.workaround 2021-01-24 02:36:13.468840410 +0900
+++ flexmock-2.3.6/test/partial_mock_test.rb 2021-01-24 03:03:55.748278701 +0900
@@ -621,7 +621,8 @@
exception = assert_raises(NameError) do
obj.mocked_method
end
- assert_equal "undefined method `does_not_exist' for #{obj}", exception.message
+ assert(/undefined method `does_not_exist' for #<#<Class:/ === exception.message,
+ "expected #{exception.message} to match /undefined method `does_not_exist' for #<#<Class:/")
end
def test_it_checks_whether_mocks_are_forbidden_before_forwarding_the_call

View File

@ -2,11 +2,14 @@
Summary: Mock object library for ruby
Name: rubygem-%{gem_name}
Version: 2.3.6
Release: 1
Release: 2
License: MIT
URL: https://github.com/doudou/flexmock
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
Source1: https://github.com/doudou/%{gem_name}/archive/v%{version}.tar.gz
Patch1: rubygem-flexmock-2.3.6-testsuite-binding-source.patch
Patch2: rubygem-flexmock-2.3.6-accept-keywords.patch
Patch3: rubygem-flexmock-2.3.6-workaround-relax-error-message.patch
Requires: ruby(release)
BuildRequires: ruby(release) rubygems-devel rubygem(minitest) >= 5 rubygem(rspec) >= 3
Requires: ruby(rubygems)
@ -25,12 +28,24 @@ Obsoletes: %{name}-doc < %{version}-%{release}
This package contains documentation for %{name}.
%prep
%setup -q -c -T
%gem_install -n %{SOURCE0}
gem unpack %{SOURCE0}
%setup -q -D -T -n %{gem_name}-%{version} -a 1
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
(
cd %{gem_name}-%{version}
%patch1 -p1
%patch3 -p1
)
%patch2 -p1
find . -name \*.rb | xargs sed -i -e '\@/usr/bin/env@d'
find . -name \*.gem -or -name \*.rb -or -name \*.rdoc | xargs chmod 0644
%build
gem build %{gem_name}.gemspec
%gem_install
%install
mkdir -p %{buildroot}%{gem_dir}
@ -46,12 +61,13 @@ rm -rf \
popd
%check
cp -a %{gem_name}-%{version}/test .%{gem_instdir}
pushd .%{gem_instdir}
pwd
ls
tar xf %{SOURCE1}
mv %{gem_name}-%{version}/test .
ruby -Ilib:.:test \
export RUBYOPT=-W:deprecated
export RUBYLIB=$(pwd)/lib:$(pwd):$(pwd)/test
ruby \
-e 'Dir.glob("test/*_test.rb").each {|f| require f}'
rspec test/rspec_integration/
popd
@ -70,5 +86,8 @@ popd
%{gem_docdir}/
%changelog
* Tue Feb 22 2022 chenchen <chen_aka_jan@163.com> - 2.3.6-2
- fix build error by upgrading to ruby3
* Mon Aug 24 2020 xiezheng <xiezheng4@huawei.com> - 2.3.6-1
- package init