Make test not depend on macOS version.

This commit is contained in:
Markus Reiter 2023-04-11 21:02:10 +02:00
parent f9e88a864e
commit 3275b927b8
No known key found for this signature in database
GPG Key ID: 245293B51702655B
4 changed files with 28 additions and 112 deletions

View File

@ -217,23 +217,18 @@ describe Cask::Cask, :cask do
end
describe "#to_h" do
let(:expected_json) { File.read("#{TEST_FIXTURE_DIR}/cask/everything.json").strip }
let(:expected_json_after_ventura) do
File.read("#{TEST_FIXTURE_DIR}/cask/everything-systemsettings-caveats.json").strip
end
let(:expected_json) { (TEST_FIXTURE_DIR/"cask/everything.json").read.strip }
context "when loaded from cask file" do
it "returns expected hash" do
allow(MacOS).to receive(:version).and_return(MacOS::Version.new("13"))
hash = Cask::CaskLoader.load("everything").to_h
expect(hash).to be_a(Hash)
if MacOS.version >= :ventura
expect(JSON.pretty_generate(hash)).to eq(expected_json_after_ventura)
else
expect(JSON.pretty_generate(hash)).to eq(expected_json)
end
end
end
context "when loaded from json file" do
it "returns expected hash" do

View File

@ -4,10 +4,31 @@
require "test/cask/dsl/shared_examples/base"
describe Cask::DSL::Caveats, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) }
let(:dsl) { described_class.new(cask) }
subject(:caveats) { described_class.new(cask) }
let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) }
let(:dsl) { caveats }
it_behaves_like Cask::DSL::Base
# TODO: add tests for Caveats DSL methods
describe "#kext" do
let(:cask) { instance_double(Cask::Cask) }
it "points to System Preferences on macOS Monterey and earlier" do
allow(MacOS).to receive(:version).and_return(MacOS::Version.new("12"))
caveats.eval_caveats do
kext
end
expect(caveats.to_s).to include("System Preferences → Security & Privacy → General")
end
it "points to System Settings on macOS Ventura and later" do
allow(MacOS).to receive(:version).and_return(MacOS::Version.new("13"))
caveats.eval_caveats do
kext
end
expect(caveats.to_s).to include("System Settings → Privacy & Security")
end
end
end

View File

@ -1,100 +0,0 @@
{
"token": "everything",
"full_token": "everything",
"tap": "homebrew/cask",
"name": [
"Everything"
],
"desc": "Little bit of everything",
"homepage": "https://www.everything.app/",
"url": "https://cachefly.everything.app/releases/Everything_1.2.3.zip",
"url_specs": {
"cookies": {
"ALL": "1234"
},
"user_agent": ":fake"
},
"appcast": null,
"version": "1.2.3",
"versions": {
},
"installed": null,
"outdated": false,
"sha256": "c64c05bdc0be845505d6e55e69e696a7f50d40846e76155f0c85d5ff5e7bbb84",
"artifacts": [
{
"uninstall": [
{
"launchctl": "com.every.thing.agent",
"delete": [
"/Library/EverythingHelperTools"
],
"kext": "com.every.thing.driver",
"signal": [
[
"TERM",
"com.every.thing.controller1"
],
[
"TERM",
"com.every.thing.bin"
]
]
}
]
},
{
"installer": [
{
"script": {
"executable": "~/just/another/path/install.sh",
"args": [
"--mode=silent"
],
"sudo": true,
"print_stderr": false
}
}
]
},
{
"app": [
"Everything.app"
]
},
{
"zap": [
{
"trash": [
"~/.everything",
"~/Library/Everything"
]
}
]
}
],
"caveats": "Installing everything might take a while...\n\neverything requires a kernel extension to work.\nIf the installation fails, retry after you enable it in:\n System Settings → Privacy & Security\n\nFor more information, refer to vendor documentation or this Apple Technical Note:\n https://developer.apple.com/library/content/technotes/tn2459/_index.html\n",
"depends_on": {
"cask": [
"something"
]
},
"conflicts_with": {
"formula": [
"nothing"
]
},
"container": {
"type": "naked"
},
"auto_updates": true,
"tap_git_head": null,
"languages": [
"en",
"eo"
],
"ruby_source_path": "Casks/everything.rb",
"ruby_source_checksum": {
"sha256": "b2707d1952f02c3fa566b7ad2a707a847a959d36f51d3dee642dbe5deec12f27"
}
}

View File

@ -73,7 +73,7 @@
]
}
],
"caveats": "Installing everything might take a while...\n\neverything requires a kernel extension to work.\nIf the installation fails, retry after you enable it in:\n System Preferences → Security & Privacy → General\n\nFor more information, refer to vendor documentation or this Apple Technical Note:\n https://developer.apple.com/library/content/technotes/tn2459/_index.html\n",
"caveats": "Installing everything might take a while...\n\neverything requires a kernel extension to work.\nIf the installation fails, retry after you enable it in:\n System Settings → Privacy & Security\n\nFor more information, refer to vendor documentation or this Apple Technical Note:\n https://developer.apple.com/library/content/technotes/tn2459/_index.html\n",
"depends_on": {
"cask": [
"something"