Only include differring versions
Move the resetting of `MacOS.version` to an `ensure` block. Fix the tests by adding a test OS and new fixture that has a different version for that test OS.
This commit is contained in:
parent
663cc40139
commit
c3a8b3841e
@ -88,11 +88,13 @@ module Cask
|
|||||||
|
|
||||||
MacOS::Version::SYMBOLS.each do |os_name, os_version|
|
MacOS::Version::SYMBOLS.each do |os_name, os_version|
|
||||||
MacOS.full_version = os_version
|
MacOS.full_version = os_version
|
||||||
version_os_hash[os_name] = CaskLoader.load(token).version
|
cask = CaskLoader.load(token)
|
||||||
|
version_os_hash[os_name] = cask.version if cask.version != version
|
||||||
end
|
end
|
||||||
|
|
||||||
MacOS.full_version = actual_version
|
|
||||||
version_os_hash
|
version_os_hash
|
||||||
|
ensure
|
||||||
|
MacOS.full_version = actual_version
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ describe Cask::Cmd::List, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "lists json" do
|
describe "lists json" do
|
||||||
let(:casks) { ["local-caffeine", "local-transmission", "third-party/tap/third-party-cask"] }
|
let(:casks) { ["local-caffeine", "local-transmission", "multiple-versions", "third-party/tap/third-party-cask"] }
|
||||||
let(:expected_output) {
|
let(:expected_output) {
|
||||||
<<~EOS
|
<<~EOS
|
||||||
[
|
[
|
||||||
@ -100,6 +100,8 @@ describe Cask::Cmd::List, :cask do
|
|||||||
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip",
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip",
|
||||||
"appcast": null,
|
"appcast": null,
|
||||||
"version": "1.2.3",
|
"version": "1.2.3",
|
||||||
|
"versions": {
|
||||||
|
},
|
||||||
"installed": "1.2.3",
|
"installed": "1.2.3",
|
||||||
"outdated": false,
|
"outdated": false,
|
||||||
"sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
|
"sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
|
||||||
@ -127,6 +129,8 @@ describe Cask::Cmd::List, :cask do
|
|||||||
"url": "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg",
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg",
|
||||||
"appcast": null,
|
"appcast": null,
|
||||||
"version": "2.61",
|
"version": "2.61",
|
||||||
|
"versions": {
|
||||||
|
},
|
||||||
"installed": "2.61",
|
"installed": "2.61",
|
||||||
"outdated": false,
|
"outdated": false,
|
||||||
"sha256": "e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68",
|
"sha256": "e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68",
|
||||||
@ -142,6 +146,36 @@ describe Cask::Cmd::List, :cask do
|
|||||||
"container": null,
|
"container": null,
|
||||||
"auto_updates": null
|
"auto_updates": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"token": "multiple-versions",
|
||||||
|
"full_token": "multiple-versions",
|
||||||
|
"tap": "homebrew/cask",
|
||||||
|
"name": [
|
||||||
|
|
||||||
|
],
|
||||||
|
"desc": null,
|
||||||
|
"homepage": "https://brew.sh/",
|
||||||
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip",
|
||||||
|
"appcast": null,
|
||||||
|
"version": "1.2.3",
|
||||||
|
"versions": {
|
||||||
|
"test_os": "1.2.0"
|
||||||
|
},
|
||||||
|
"installed": "1.2.3",
|
||||||
|
"outdated": false,
|
||||||
|
"sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
|
||||||
|
"artifacts": [
|
||||||
|
[
|
||||||
|
"Caffeine.app"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"caveats": null,
|
||||||
|
"depends_on": {
|
||||||
|
},
|
||||||
|
"conflicts_with": null,
|
||||||
|
"container": null,
|
||||||
|
"auto_updates": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"token": "third-party-cask",
|
"token": "third-party-cask",
|
||||||
"full_token": "third-party/tap/third-party-cask",
|
"full_token": "third-party/tap/third-party-cask",
|
||||||
@ -154,6 +188,8 @@ describe Cask::Cmd::List, :cask do
|
|||||||
"url": "https://brew.sh/ThirdParty.dmg",
|
"url": "https://brew.sh/ThirdParty.dmg",
|
||||||
"appcast": null,
|
"appcast": null,
|
||||||
"version": "1.2.3",
|
"version": "1.2.3",
|
||||||
|
"versions": {
|
||||||
|
},
|
||||||
"installed": "1.2.3",
|
"installed": "1.2.3",
|
||||||
"outdated": false,
|
"outdated": false,
|
||||||
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b",
|
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b",
|
||||||
@ -175,6 +211,11 @@ describe Cask::Cmd::List, :cask do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
casks.map(&Cask::CaskLoader.method(:load)).each(&InstallHelper.method(:install_with_caskfile))
|
casks.map(&Cask::CaskLoader.method(:load)).each(&InstallHelper.method(:install_with_caskfile))
|
||||||
|
|
||||||
|
# Add a test OS to ensure that all cask versions are listed regardless of OS.
|
||||||
|
symbols = MacOS::Version::SYMBOLS.dup
|
||||||
|
symbols[:test_os] = "10.9"
|
||||||
|
stub_const("MacOS::Version::SYMBOLS", symbols)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "of all installed Casks" do
|
it "of all installed Casks" do
|
||||||
@ -185,7 +226,8 @@ describe Cask::Cmd::List, :cask do
|
|||||||
|
|
||||||
it "of given Casks" do
|
it "of given Casks" do
|
||||||
expect {
|
expect {
|
||||||
described_class.run("--json", "local-caffeine", "local-transmission", "third-party/tap/third-party-cask")
|
described_class.run("--json", "local-caffeine", "local-transmission", "multiple-versions",
|
||||||
|
"third-party/tap/third-party-cask")
|
||||||
}.to output(expected_output).to_stdout
|
}.to output(expected_output).to_stdout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
cask "multiple-versions" do
|
||||||
|
if MacOS.version == :test_os
|
||||||
|
version "1.2.0"
|
||||||
|
else
|
||||||
|
version "1.2.3"
|
||||||
|
end
|
||||||
|
sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
|
||||||
|
homepage "https://brew.sh/"
|
||||||
|
|
||||||
|
app "Caffeine.app"
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user