!2 fix NameError compare failure
From: @wang--ge Reviewed-by: @small_leek Signed-off-by: @small_leek
This commit is contained in:
commit
3f74fd9160
81
0001-fix-NameError-compare-failure.patch
Normal file
81
0001-fix-NameError-compare-failure.patch
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
From 9900662414c5f87c106e7f23dad9afe4ba2c3af2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wang--ge <wang__ge@126.com>
|
||||||
|
Date: Thu, 5 Jan 2023 15:27:28 +0800
|
||||||
|
Subject: [PATCH] fix NameError compare failure
|
||||||
|
|
||||||
|
---
|
||||||
|
lib/rspec/matchers/built_in/raise_error.rb | 12 +++++++++---
|
||||||
|
spec/rspec/matchers/raise_error_spec.rb | 8 ++++----
|
||||||
|
2 files changed, 13 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/rspec/matchers/built_in/raise_error.rb b/lib/rspec/matchers/built_in/raise_error.rb
|
||||||
|
index 633b3fc..5f85e29 100644
|
||||||
|
--- a/lib/rspec/matchers/built_in/raise_error.rb
|
||||||
|
+++ b/lib/rspec/matchers/built_in/raise_error.rb
|
||||||
|
@@ -72,14 +72,14 @@ module RSpec
|
||||||
|
when nil
|
||||||
|
true
|
||||||
|
when Regexp
|
||||||
|
- @expected_message =~ @actual_error.message
|
||||||
|
+ @expected_message =~ actual_error_message
|
||||||
|
else
|
||||||
|
- @expected_message == @actual_error.message
|
||||||
|
+ @expected_message == actual_error_message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def failure_message_for_should
|
||||||
|
- @eval_block ? @actual_error.message : "expected #{expected_error}#{given_error}"
|
||||||
|
+ @eval_block ? actual_error_message : "expected #{expected_error}#{given_error}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def failure_message_for_should_not
|
||||||
|
@@ -92,6 +92,12 @@ module RSpec
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
+ def actual_error_message
|
||||||
|
+ return nil unless @actual_error
|
||||||
|
+
|
||||||
|
+ @actual_error.respond_to?(:original_message) ? @actual_error.original_message : @actual_error.message
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
def expected_error
|
||||||
|
case @expected_message
|
||||||
|
when nil
|
||||||
|
diff --git a/spec/rspec/matchers/raise_error_spec.rb b/spec/rspec/matchers/raise_error_spec.rb
|
||||||
|
index 54a097b..7b6a900 100644
|
||||||
|
--- a/spec/rspec/matchers/raise_error_spec.rb
|
||||||
|
+++ b/spec/rspec/matchers/raise_error_spec.rb
|
||||||
|
@@ -133,7 +133,7 @@ describe "expect { ... }.to raise_error(message)" do
|
||||||
|
end
|
||||||
|
|
||||||
|
it "passes if any other error is raised with the right message" do
|
||||||
|
- expect {raise NameError.new('blah')}.to raise_error('blah')
|
||||||
|
+ expect {raise NameError}.to raise_error(NameError)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails if RuntimeError error is raised with the wrong message" do
|
||||||
|
@@ -145,7 +145,7 @@ describe "expect { ... }.to raise_error(message)" do
|
||||||
|
it "fails if any other error is raised with the wrong message" do
|
||||||
|
expect do
|
||||||
|
expect {raise NameError.new('blarg')}.to raise_error('blah')
|
||||||
|
- end.to fail_with(/expected Exception with \"blah\", got #<NameError: blarg>/)
|
||||||
|
+ end.to fail_with(/expected Exception with \"blah\", got #<NameError: blarg/)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes the backtrace of any other error in the failure message' do
|
||||||
|
@@ -197,8 +197,8 @@ describe "expect { ... }.not_to raise_error(message)" do
|
||||||
|
|
||||||
|
it "fails if any other error is raised with message" do
|
||||||
|
expect do
|
||||||
|
- expect {raise NameError.new('blah')}.not_to raise_error('blah')
|
||||||
|
- end.to fail_with(/expected no Exception with "blah", got #<NameError: blah>/)
|
||||||
|
+ expect {raise NameError.new('blah')}.not_to raise_error(NameError)
|
||||||
|
+ end.to fail_with(/expected no NameError/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
Summary: Rspec 2 expectations (should and matchers)
|
Summary: Rspec 2 expectations (should and matchers)
|
||||||
Name: rubygem-%{rpmgem_name}
|
Name: rubygem-%{rpmgem_name}
|
||||||
Version: %{majorver}
|
Version: %{majorver}
|
||||||
Release: 1
|
Release: 2
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://github.com/rspec/rspec-expectations
|
URL: http://github.com/rspec/rspec-expectations
|
||||||
Source0: https://rubygems.org/gems/%{gem_name}-%{fullver}.gem
|
Source0: https://rubygems.org/gems/%{gem_name}-%{fullver}.gem
|
||||||
@ -17,6 +17,7 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{fullver}.gem
|
|||||||
Patch0: rubygem-rspec-expectations-2.14.5-be_truthy-alias.patch
|
Patch0: rubygem-rspec-expectations-2.14.5-be_truthy-alias.patch
|
||||||
# Test suite fix for ruby24 wrt integer unification
|
# Test suite fix for ruby24 wrt integer unification
|
||||||
Patch1: rubygem-rspec-expectations-2.14.5-ruby24.patch
|
Patch1: rubygem-rspec-expectations-2.14.5-ruby24.patch
|
||||||
|
Patch2: 0001-fix-NameError-compare-failure.patch
|
||||||
BuildRequires: ruby(release) rubygems-devel
|
BuildRequires: ruby(release) rubygems-devel
|
||||||
%if 0%{?need_bootstrap} < 1
|
%if 0%{?need_bootstrap} < 1
|
||||||
BuildRequires: rubygem(rspec2) %gem_minitest rubygem(test-unit)
|
BuildRequires: rubygem(rspec2) %gem_minitest rubygem(test-unit)
|
||||||
@ -40,6 +41,7 @@ gem unpack %{SOURCE0}
|
|||||||
%setup -q -D -T -n %{gem_name}-%{version}
|
%setup -q -D -T -n %{gem_name}-%{version}
|
||||||
%patch0 -p2
|
%patch0 -p2
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
|
%patch2 -p1
|
||||||
sed -i -e "s@\(require 'test/unit'\)@gem 'minitest', '~> 4' ;\1@" \
|
sed -i -e "s@\(require 'test/unit'\)@gem 'minitest', '~> 4' ;\1@" \
|
||||||
spec/spec_helper.rb
|
spec/spec_helper.rb
|
||||||
gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
||||||
@ -76,5 +78,8 @@ popd
|
|||||||
%exclude %{gem_instdir}/spec/
|
%exclude %{gem_instdir}/spec/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jan 17 2023 Ge Wang <wangge20@h-partners.com> - %{majorver}-2
|
||||||
|
- fix NameError compare failure
|
||||||
|
|
||||||
* Wed Aug 19 2020 huangyangke <huangyangke@huawei.com> - %{majorver}-1
|
* Wed Aug 19 2020 huangyangke <huangyangke@huawei.com> - %{majorver}-1
|
||||||
- package init
|
- package init
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user