From 9c0d3452201ee1a292aa90b383d025469710f150 Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Wed, 29 May 2024 17:29:40 -0700 Subject: [PATCH] Remove ostruct dependency (#196) Starting in Ruby 3.4, the following deprecation warning is printed when running the childprocess specs: > childprocess/spec/spec_helper.rb:14: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0. Add ostruct to your Gemfile or gemspec. This commit fixes this warning by removing our dependency on the `ostruct` gem entirely, replacing it with a normal `Struct`. --- spec/spec_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f548bbb..b136d9f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,10 +11,10 @@ require 'tempfile' require 'socket' require 'stringio' -require 'ostruct' module ChildProcessSpecHelper RUBY = defined?(Gem) ? Gem.ruby : 'ruby' + CapturedOutput = Struct.new(:stdout, :stderr) def ruby_process(*args) @process = ChildProcess.build(RUBY , *args) @@ -229,7 +229,7 @@ def capture_std yield - OpenStruct.new stdout: rewind_and_read(out), stderr: rewind_and_read(err) + CapturedOutput.new rewind_and_read(out), rewind_and_read(err) ensure STDOUT.reopen orig_out STDERR.reopen orig_err