Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test not depend on macOS version. #15206

Merged
merged 2 commits into from Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 4 additions & 9 deletions Library/Homebrew/test/cask/cask_spec.rb
Expand Up @@ -217,21 +217,16 @@
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
expect(JSON.pretty_generate(hash)).to eq(expected_json)
end
end

Expand Down
24 changes: 23 additions & 1 deletion Library/Homebrew/test/cask/dsl/caveats_spec.rb
Expand Up @@ -4,10 +4,32 @@
require "test/cask/dsl/shared_examples/base"

describe Cask::DSL::Caveats, :cask do
subject(:caveats) { described_class.new(cask) }

let(:cask) { Cask::CaskLoader.load(cask_path("basic-cask")) }
let(:dsl) { described_class.new(cask) }
let(:dsl) { caveats }

it_behaves_like Cask::DSL::Base
reitermarkus marked this conversation as resolved.
Show resolved Hide resolved

# 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

This file was deleted.

Expand Up @@ -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 PreferencesSecurity & 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 SettingsPrivacy & 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"
Expand Down