From e08d5f113c86e5c5889bb1c94bf4d3acaaf0478a Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Thu, 26 Aug 2021 23:35:33 -0400 Subject: [PATCH] Make `Homebrew::API::Versions#latest_cask_version` tests macOS-only --- Library/Homebrew/test/api/versions_spec.rb | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Library/Homebrew/test/api/versions_spec.rb b/Library/Homebrew/test/api/versions_spec.rb index 234ef081aa..c27ec833dd 100644 --- a/Library/Homebrew/test/api/versions_spec.rb +++ b/Library/Homebrew/test/api/versions_spec.rb @@ -4,30 +4,21 @@ require "api" describe Homebrew::API::Versions do - let(:versions_formulae_json) { - <<~EOS - { - "foo":{"version":"1.2.3","revision":0}, - "bar":{"version":"1.2","revision":4} - } - EOS - } - let(:versions_casks_json) { - <<~EOS - { - "foo":{"version":"1.2.3","versions":{}}, - "bar":{"version":"1.2.3","versions":{"#{MacOS.version.to_sym}":"1.2.0"}}, - "baz":{"version":"1.2.3","versions":{"test_os":"1.2.0"}} - } - EOS - } - def mock_curl_output(stdout: "", success: true) curl_output = OpenStruct.new(stdout: stdout, success?: success) allow(Utils::Curl).to receive(:curl_output).and_return curl_output end describe "::latest_formula_version" do + let(:versions_formulae_json) { + <<~EOS + { + "foo":{"version":"1.2.3","revision":0}, + "bar":{"version":"1.2","revision":4} + } + EOS + } + it "returns the expected `PkgVersion` when the revision is 0" do mock_curl_output stdout: versions_formulae_json pkg_version = described_class.latest_formula_version("foo") @@ -47,7 +38,17 @@ describe Homebrew::API::Versions do end end - describe "::latest_cask_version" do + describe "::latest_cask_version", :needs_macos do + let(:versions_casks_json) { + <<~EOS + { + "foo":{"version":"1.2.3","versions":{}}, + "bar":{"version":"1.2.3","versions":{"#{MacOS.version.to_sym}":"1.2.0"}}, + "baz":{"version":"1.2.3","versions":{"test_os":"1.2.0"}} + } + EOS + } + it "returns the expected `Version`" do mock_curl_output stdout: versions_casks_json version = described_class.latest_cask_version("foo")