Blob Blame History Raw
From 1dd089fc97e44066982cec62b8264dd03b1df531 Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Tue, 20 Dec 2022 23:27:59 +0900
Subject: [PATCH] ansible/provisioner_test: fix for ruby32 Kernel#=~ removal

Kernel#=~ has done nothing and just has returned nil, and
now with ruby3.2 this deprecated method is removed.

So for $ bundle exec rake under ruby 3.2, check if variable
really accepts =~ method first.

Fixes #13028 .
---
 test/unit/plugins/provisioners/ansible/provisioner_test.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb
index f5828f14340..15fb3bbdcf1 100644
--- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb
+++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb
@@ -91,7 +91,7 @@ def self.it_should_set_arguments_and_environment_variables(
         expect(args[1]).to eq("--connection=ssh")
         expect(args[2]).to eq("--timeout=30")
 
-        inventory_count = args.count { |x| x =~ /^--inventory-file=.+$/ }
+        inventory_count = args.count { |x| x.respond_to?(:=~) && x =~ /^--inventory-file=.+$/ }
         expect(inventory_count).to be > 0
 
         expect(args[args.length-2]).to eq("playbook.yml")
@@ -100,9 +100,9 @@ def self.it_should_set_arguments_and_environment_variables(
 
     it "sets --limit argument" do
       expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args) { |*args|
-        all_limits = args.select { |x| x =~ /^(--limit=|-l)/ }
+        all_limits = args.select { |x| x.respond_to?(:=~) && x =~ /^(--limit=|-l)/ }
         if config.raw_arguments
-          raw_limits = config.raw_arguments.select { |x| x =~ /^(--limit=|-l)/ }
+          raw_limits = config.raw_arguments.select { |x| x.respond_to?(:=~) && x =~ /^(--limit=|-l)/ }
           expect(all_limits.length - raw_limits.length).to eq(1)
           expect(all_limits.last).to eq(raw_limits.last)
         else