Fix tests and improve style
This commit is contained in:
parent
57417dd016
commit
5e5c78ebef
@ -93,7 +93,7 @@ module OnSystem
|
|||||||
base.define_method(:on_system) do |linux, macos:, &block|
|
base.define_method(:on_system) do |linux, macos:, &block|
|
||||||
@on_system_blocks_exist = true
|
@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_")
|
os_version, or_condition = if macos.to_s.include?("_or_")
|
||||||
macos.to_s.split(/_(?=or_)/).map(&:to_sym)
|
macos.to_s.split(/_(?=or_)/).map(&:to_sym)
|
||||||
|
|||||||
@ -1604,35 +1604,35 @@ describe Formula do
|
|||||||
end.new
|
end.new
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't call code on Ventura" do
|
it "doesn't call code on Ventura", :needs_macos do
|
||||||
Homebrew::SimulateSystem.os = :ventura
|
Homebrew::SimulateSystem.os = :ventura
|
||||||
f.brew { f.install }
|
f.brew { f.install }
|
||||||
expect(f.foo).to eq(0)
|
expect(f.foo).to eq(0)
|
||||||
expect(f.bar).to eq(0)
|
expect(f.bar).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls code on Linux" do
|
it "calls code on Linux", :needs_linux do
|
||||||
Homebrew::SimulateSystem.os = :linux
|
Homebrew::SimulateSystem.os = :linux
|
||||||
f.brew { f.install }
|
f.brew { f.install }
|
||||||
expect(f.foo).to eq(1)
|
expect(f.foo).to eq(1)
|
||||||
expect(f.bar).to eq(1)
|
expect(f.bar).to eq(1)
|
||||||
end
|
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
|
Homebrew::SimulateSystem.os = :monterey
|
||||||
f.brew { f.install }
|
f.brew { f.install }
|
||||||
expect(f.foo).to eq(1)
|
expect(f.foo).to eq(1)
|
||||||
expect(f.bar).to eq(0)
|
expect(f.bar).to eq(0)
|
||||||
end
|
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
|
Homebrew::SimulateSystem.os = :big_sur
|
||||||
f.brew { f.install }
|
f.brew { f.install }
|
||||||
expect(f.foo).to eq(0)
|
expect(f.foo).to eq(0)
|
||||||
expect(f.bar).to eq(1)
|
expect(f.bar).to eq(1)
|
||||||
end
|
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
|
Homebrew::SimulateSystem.os = :catalina
|
||||||
f.brew { f.install }
|
f.brew { f.install }
|
||||||
expect(f.foo).to eq(0)
|
expect(f.foo).to eq(0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user