Skip to content

Commit

Permalink
Add conditions for ruby version < 3.1 to install mocha accordingly
Browse files Browse the repository at this point in the history
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
  • Loading branch information
ahasunos committed Oct 12, 2023
1 parent 5d57c99 commit 5f1ad7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ group :test do
# but it's close enough to show the gempath handler can find a plugin
# See test/unit/
gem "train-test-fixture", path: "test/fixtures/plugins/train-test-fixture"
gem "mocha", "~> 2.1"
# 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")
end

if Gem.ruby_version >= Gem::Version.new("2.7.0")
Expand Down
4 changes: 2 additions & 2 deletions test/unit/transports/ssh_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
end

it "sets up a proxy when ssh proxy command is specified" do
mock = Minitest::Mock.new
mock = RUBY_VERSION < "3.1" ? MiniTest::Mock.new : Minitest::Mock.new
mock.expect(:call, true) do |hostname, username, options|
options[:proxy].is_a?(Net::SSH::Proxy::Command) &&
"ssh root@127.0.0.1 -W %h:%p" == options[:proxy].command_line_template
Expand Down Expand Up @@ -384,7 +384,7 @@
end

it "sets up a proxy when ssh proxy command is specified" do
mock = Minitest::Mock.new
mock = RUBY_VERSION < "3.1" ? MiniTest::Mock.new : Minitest::Mock.new
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
Expand Down

0 comments on commit 5f1ad7b

Please sign in to comment.