Fix tests and improve style

This commit is contained in:
Rylan Polster 2022-07-11 04:03:37 -04:00
parent 57417dd016
commit 5e5c78ebef
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
2 changed files with 6 additions and 6 deletions

View File

@ -93,7 +93,7 @@ module OnSystem
base.define_method(:on_system) do |linux, macos:, &block|
@on_system_blocks_exist = true
raise ArgumentError, "The first argument to `on_system` must be `:linux`" unless linux == :linux
raise ArgumentError, "The first argument to `on_system` must be `:linux`" if linux != :linux
os_version, or_condition = if macos.to_s.include?("_or_")
macos.to_s.split(/_(?=or_)/).map(&:to_sym)

View File

@ -1604,35 +1604,35 @@ describe Formula do
end.new
end
it "doesn't call code on Ventura" do
it "doesn't call code on Ventura", :needs_macos do
Homebrew::SimulateSystem.os = :ventura
f.brew { f.install }
expect(f.foo).to eq(0)
expect(f.bar).to eq(0)
end
it "calls code on Linux" do
it "calls code on Linux", :needs_linux do
Homebrew::SimulateSystem.os = :linux
f.brew { f.install }
expect(f.foo).to eq(1)
expect(f.bar).to eq(1)
end
it "calls code within `on_system :linux, macos: :monterey` on Monterey" do
it "calls code within `on_system :linux, macos: :monterey` on Monterey", :needs_macos do
Homebrew::SimulateSystem.os = :monterey
f.brew { f.install }
expect(f.foo).to eq(1)
expect(f.bar).to eq(0)
end
it "calls code within `on_system :linux, macos: :big_sur_or_older` on Big Sur" do
it "calls code within `on_system :linux, macos: :big_sur_or_older` on Big Sur", :needs_macos do
Homebrew::SimulateSystem.os = :big_sur
f.brew { f.install }
expect(f.foo).to eq(0)
expect(f.bar).to eq(1)
end
it "calls code within `on_system :linux, macos: :big_sur_or_older` on Catalina" do
it "calls code within `on_system :linux, macos: :big_sur_or_older` on Catalina", :needs_macos do
Homebrew::SimulateSystem.os = :catalina
f.brew { f.install }
expect(f.foo).to eq(0)