1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
From: =?utf-8?q?Romain_Tarti=C3=A8re?= <romain@blogreen.org>
Date: Wed, 30 Oct 2024 16:34:59 -1000
Subject: [PATCH] Fix CI with latest yard
Monkey patching libraries is a bad idea. Latest version of yard changed
some internal details, which broke CI.
A workaround was proposed in #401 but the root cause was not addressed.
In this commit, we replace the private `io` object with an instance of a
class that provide the expected `IO#write` method instead of `nil` which
does not provide this interface in CI, so that the issue is not raised
anymore.
---
puppet-strings.gemspec | 2 +-
.../puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/puppet-strings.gemspec b/puppet-strings.gemspec
index 13240f7..6a8d216 100644
--- a/puppet-strings.gemspec
+++ b/puppet-strings.gemspec
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*']
s.add_runtime_dependency 'rgen', '~> 0.9'
- s.add_runtime_dependency 'yard', '~> 0.9', '< 0.9.37'
+ s.add_runtime_dependency 'yard', '~> 0.9'
s.requirements << 'puppet, >= 7.0.0'
end
diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb
index 474eca3..8ffb08b 100644
--- a/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb
+++ b/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb
@@ -3,6 +3,10 @@
require 'spec_helper'
require 'puppet-strings/yard'
+class NullLogger
+ def write(_message); end
+end
+
describe PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler, if: TEST_PUPPET_DATATYPES do
subject(:spec_subject) do
YARD::Parser::SourceParser.parse_string(source, :ruby)
@@ -19,7 +23,7 @@ describe PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler, if: TEST_PUPPET_D
end
def suppress_yard_logging
- YARD::Logger.instance.io = nil
+ YARD::Logger.instance.io = NullLogger.new
end
describe 'parsing source without a data type definition' do
|