fix build error by upgrading to ruby3

(cherry picked from commit 167f372e457c0b817620573165b7a92c49ed5bda)
This commit is contained in:
chen-jan 2022-02-22 09:27:47 +08:00 committed by openeuler-sync-bot
parent 18269ec602
commit b442c66bc2
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 Summary: Mock object library for ruby
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Version: 2.3.6 Version: 2.3.6
Release: 1 Release: 2
License: MIT License: MIT
URL: https://github.com/doudou/flexmock URL: https://github.com/doudou/flexmock
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
Source1: https://github.com/doudou/%{gem_name}/archive/v%{version}.tar.gz 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) Requires: ruby(release)
BuildRequires: ruby(release) rubygems-devel rubygem(minitest) >= 5 rubygem(rspec) >= 3 BuildRequires: ruby(release) rubygems-devel rubygem(minitest) >= 5 rubygem(rspec) >= 3
Requires: ruby(rubygems) Requires: ruby(rubygems)
@ -25,12 +28,24 @@ Obsoletes: %{name}-doc < %{version}-%{release}
This package contains documentation for %{name}. This package contains documentation for %{name}.
%prep %prep
%setup -q -c -T gem unpack %{SOURCE0}
%gem_install -n %{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 \*.rb | xargs sed -i -e '\@/usr/bin/env@d'
find . -name \*.gem -or -name \*.rb -or -name \*.rdoc | xargs chmod 0644 find . -name \*.gem -or -name \*.rb -or -name \*.rdoc | xargs chmod 0644
%build %build
gem build %{gem_name}.gemspec
%gem_install
%install %install
mkdir -p %{buildroot}%{gem_dir} mkdir -p %{buildroot}%{gem_dir}
@ -46,12 +61,13 @@ rm -rf \
popd popd
%check %check
cp -a %{gem_name}-%{version}/test .%{gem_instdir}
pushd .%{gem_instdir} pushd .%{gem_instdir}
pwd pwd
ls ls
tar xf %{SOURCE1} export RUBYOPT=-W:deprecated
mv %{gem_name}-%{version}/test . export RUBYLIB=$(pwd)/lib:$(pwd):$(pwd)/test
ruby -Ilib:.:test \ ruby \
-e 'Dir.glob("test/*_test.rb").each {|f| require f}' -e 'Dir.glob("test/*_test.rb").each {|f| require f}'
rspec test/rspec_integration/ rspec test/rspec_integration/
popd popd
@ -70,5 +86,8 @@ popd
%{gem_docdir}/ %{gem_docdir}/
%changelog %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 * Mon Aug 24 2020 xiezheng <xiezheng4@huawei.com> - 2.3.6-1
- package init - package init