diff --git a/Library/Homebrew/extend/on_system.rb b/Library/Homebrew/extend/on_system.rb index 98703fb79f..5ec59cbdfa 100644 --- a/Library/Homebrew/extend/on_system.rb +++ b/Library/Homebrew/extend/on_system.rb @@ -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) diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index a368fee1d0..e47a197361 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -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)