Allow multiple JSON outputs

This commit is contained in:
Douglas Eichelberger 2024-11-07 09:34:44 -08:00
parent c17ffb8c3b
commit acb4eddaca

View File

@ -20,9 +20,12 @@ RSpec.describe Homebrew::Cmd::Outdated do
}],
casks: [],
})
# json v2.8.1 is inconsistent it how it renders empty arrays,
# for now we allow multiple outputs:
alternate_json = expected_json.gsub("[]", "[\n\n]")
expect { brew "outdated", "--json=v2" }
.to output("#{expected_json}\n").to_stdout
.to output(match(/\A(#{Regexp.escape(expected_json)}|#{Regexp.escape(alternate_json)})\n\z/)).to_stdout
.and be_a_success
end
end