Skip to content

Commit a191e18

Browse files
committed
Unit tests: Fix Ruby 2.7 compatibility
1 parent f80b94d commit a191e18

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spec/unit/outputter/human_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,15 @@
273273

274274
it "prints empty results from a plan" do
275275
outputter.print_plan_result(Bolt::PlanResult.new([], 'success'))
276-
expect(output.string).to eq("[]\n")
276+
# json 2.8 changed the array/hash formatting. Ruby 3.0 ships json 2.8+, Ruby 2.7 has an older version
277+
# interestingly, in openvox the default is the old behaviour, in bolt it's the new behaviour
278+
# https://github.com/OpenVoxProject/puppet/pull/132
279+
major_version = RUBY_VERSION.split('.').first.to_i
280+
if major_version == 2
281+
expect(output.string).to eq("[\n\n]\n")
282+
else
283+
expect(output.string).to eq("[]\n")
284+
end
277285
end
278286

279287
it "formats unwrapped ExecutionResult from a plan" do

0 commit comments

Comments
 (0)