From 019bfeab2bf30f8421708c7974372090faa87b1c Mon Sep 17 00:00:00 2001 From: Sonu Saha Date: Thu, 12 Oct 2023 11:23:42 +0530 Subject: [PATCH] Windows platform for all versions of ruby are unaffected it seems Signed-off-by: Sonu Saha --- Gemfile | 7 ++++++- test/unit/transports/ssh_test.rb | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index c993fe11..42c6826d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,12 @@ group :test do gem "train-test-fixture", path: "test/fixtures/plugins/train-test-fixture" # Mocha ~1.1 is incompatible with minitest v5.19 and later # More on the issue: https://github.com/freerange/mocha/issues/614 - gem "mocha", (RUBY_VERSION < "3.1" ? "~> 1.1" : "~> 2.1") + # It seems non-windows platforms lower than ruby 3.1 are affected + if !Gem.win_platform? && (Gem.ruby_version < Gem::Version.new("3.1")) + gem "mocha", "~> 1.1" + else + gem "mocha", "~> 2.1" + end end if Gem.ruby_version >= Gem::Version.new("2.7.0") diff --git a/test/unit/transports/ssh_test.rb b/test/unit/transports/ssh_test.rb index b306fb08..3434f305 100644 --- a/test/unit/transports/ssh_test.rb +++ b/test/unit/transports/ssh_test.rb @@ -384,7 +384,12 @@ end it "sets up a proxy when ssh proxy command is specified" do - mock = RUBY_VERSION < "3.1" ? MiniTest::Mock.new : Minitest::Mock.new + # Only non-windows ruby < 3.1 uses MiniTest::Mock + if !windows? && RUBY_VERSION < "3.1" + mock = MiniTest::Mock.new + else + mock = Minitest::Mock.new + end mock.expect(:call, true) do |hostname, username, options| options[:proxy].is_a?(Net::SSH::Proxy::Command) && "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -o ForwardAgent=no -o IdentitiesOnly=yes -i #{conf[:key_files]} root@bastion_dummy -p 22 -W %h:%p" == options[:proxy].command_line_template