From 84ad68e02b0ddefbb5757651ed98f37969e4b1f6 Mon Sep 17 00:00:00 2001 From: wang--ge Date: Tue, 17 Jan 2023 10:48:45 +0800 Subject: [PATCH] fix NameError compare failure --- 0001-fix-NameError-compare-failure.patch | 81 ++++++++++++++++++++++++ rubygem-rspec2-expectations.spec | 7 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 0001-fix-NameError-compare-failure.patch diff --git a/0001-fix-NameError-compare-failure.patch b/0001-fix-NameError-compare-failure.patch new file mode 100644 index 0000000..ff4a613 --- /dev/null +++ b/0001-fix-NameError-compare-failure.patch @@ -0,0 +1,81 @@ +From 9900662414c5f87c106e7f23dad9afe4ba2c3af2 Mon Sep 17 00:00:00 2001 +From: wang--ge +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 #/) ++ end.to fail_with(/expected Exception with \"blah\", got #/) ++ expect {raise NameError.new('blah')}.not_to raise_error(NameError) ++ end.to fail_with(/expected no NameError/) + end + end + +-- +2.27.0 + diff --git a/rubygem-rspec2-expectations.spec b/rubygem-rspec2-expectations.spec index 9007cf3..19da06d 100644 --- a/rubygem-rspec2-expectations.spec +++ b/rubygem-rspec2-expectations.spec @@ -9,7 +9,7 @@ Summary: Rspec 2 expectations (should and matchers) Name: rubygem-%{rpmgem_name} Version: %{majorver} -Release: 1 +Release: 2 License: MIT URL: http://github.com/rspec/rspec-expectations 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 # Test suite fix for ruby24 wrt integer unification Patch1: rubygem-rspec-expectations-2.14.5-ruby24.patch +Patch2: 0001-fix-NameError-compare-failure.patch BuildRequires: ruby(release) rubygems-devel %if 0%{?need_bootstrap} < 1 BuildRequires: rubygem(rspec2) %gem_minitest rubygem(test-unit) @@ -40,6 +41,7 @@ gem unpack %{SOURCE0} %setup -q -D -T -n %{gem_name}-%{version} %patch0 -p2 %patch1 -p1 +%patch2 -p1 sed -i -e "s@\(require 'test/unit'\)@gem 'minitest', '~> 4' ;\1@" \ spec/spec_helper.rb gem specification %{SOURCE0} -l --ruby > %{gem_name}.gemspec @@ -76,5 +78,8 @@ popd %exclude %{gem_instdir}/spec/ %changelog +* Tue Jan 17 2023 Ge Wang - %{majorver}-2 +- fix NameError compare failure + * Wed Aug 19 2020 huangyangke - %{majorver}-1 - package init