Fix testcase error

Signed-off-by: cherry530 <xuping33@huawei.com>
This commit is contained in:
cherry530 2023-01-17 14:12:06 +08:00
parent 191e378887
commit 50a3e52501
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From e194bf62b1d0c0828cc83405e60dc5ece829e62f Mon Sep 17 00:00:00 2001
From: Andrew Janke <andrew@apjanke.net>
Date: Fri, 6 Jan 2023 07:25:48 -0500
Subject: [PATCH] Workaround for Psych 4.0+ in tests
Psych 4.0, shipped with Ruby 3.1, switched to a "safe load" by default, and requires you to explicitly set allowed classes. But previous Psych versions didn't support this kwarg, so the call needs to be made differently depending on which version of Psych/Ruby this is running under.
Co-authored-by: Takuya Noguchi <takninnovationresearch@gmail.com>
---
test/test_ronn_document.rb | 7 ++++++-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/test/test_ronn_document.rb b/test/test_ronn_document.rb
index 75788dc..cd573fe 100644
--- a/test/test_ronn_document.rb
+++ b/test/test_ronn_document.rb
@@ -137,6 +137,11 @@ def canonicalize(text)
test 'converting to yaml' do
require 'yaml'
+ actual = begin
+ YAML.load(@doc.to_yaml, permitted_classes: [Time])
+ rescue ArgumentError # Remove this line when Ruby 3.0.x support is dropped
+ YAML.load(@doc.to_yaml)
+ end
assert_equal({
'section' => '1',
'name' => 'hello',
@@ -146,7 +151,7 @@ def canonicalize(text)
'toc' => [['NAME', 'NAME']],
'organization' => nil,
'manual' => nil
- }, YAML.load(@doc.to_yaml))
+ }, actual)
end
test 'converting to json' do

View File

@ -1,13 +1,17 @@
%global gem_name ronn-ng
Name: rubygem-%{gem_name}
Version: 0.9.1
Release: 1
Release: 2
Summary: Builds man pages from Markdown
License: MIT
URL: https://github.com/apjanke/ronn-ng
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
BuildRequires: ruby(release) rubygems-devel ruby rubygem(kramdown) rubygem(mustache)
BuildRequires: rubygem(nokogiri) rubygem(test-unit)
BuildRequires: rubygem(did_you_mean)
Patch0: Workaround-for-psych-4.0+-in-tests.patch
BuildArch: noarch
Requires: /usr/bin/groff
Provides: rubygem-ronn = %{version}-%{release}
@ -31,6 +35,7 @@ Documentation for %{name}.
%setup -q -n %{gem_name}-%{version}
%gemspec_remove_dep -g mustache "~> 0.7"
chmod -x lib/ronn.rb
%patch0 -p1
%build
gem build ../%{gem_name}-%{version}.gemspec
@ -83,5 +88,8 @@ popd
%{gem_instdir}/test
%changelog
* Tue Jan 17 2023 xu_ping <xuping33@h-partners.com> - 0.9.1-2
- fix testcase error.
* Tue Dec 15 2020 chengzihan <chengzihan2@huawei.com> - 0.9.1-1
- Package init