Only check for arguments matching test string if the argument is a string

This issue surfaced in the tests after updating to Ruby 3.2.0 where
the =~ operator has been removed.

ref: cca54c8b1b/NEWS.md (L498)
This commit is contained in:
sophia 2023-01-03 13:20:14 -08:00
parent 7661eba89a
commit 9743c85748

View File

@ -91,7 +91,7 @@ VF
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.match(/^--inventory-file=.+$/) if x.is_a?(String) }
expect(inventory_count).to be > 0
expect(args[args.length-2]).to eq("playbook.yml")
@ -100,9 +100,9 @@ VF
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.match(/^(--limit=|-l)/) if x.is_a?(String) }
if config.raw_arguments
raw_limits = config.raw_arguments.select { |x| x =~ /^(--limit=|-l)/ }
raw_limits = config.raw_arguments.select { |x| x.match(/^(--limit=|-l)/) if x.is_a?(String) }
expect(all_limits.length - raw_limits.length).to eq(1)
expect(all_limits.last).to eq(raw_limits.last)
else