
These are regression tests to make sure that this logic is reproducible. If this logic is not working, it might mean that someone removes a tap accidentally that still includes a formula or cask that they currently have installed. The tests are extravagant and over-engineered but I'm not sure that there's an easier way to do this without massive integration tests.
24 lines
830 B
Ruby
24 lines
830 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "formulary"
|
|
|
|
module Test
|
|
module Helper
|
|
module Formula
|
|
def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, tap: nil,
|
|
&block)
|
|
Class.new(::Formula, &block).new(name, path, spec, alias_path:, tap:)
|
|
end
|
|
|
|
# Use a stubbed {Formulary::FormulaLoader} to make a given formula be found
|
|
# when loading from {Formulary} with `ref`.
|
|
def stub_formula_loader(formula, ref = formula.full_name, call_original: false)
|
|
allow(Formulary).to receive(:loader_for).and_call_original if call_original
|
|
|
|
loader = instance_double(Formulary::FormulaLoader, get_formula: formula)
|
|
allow(Formulary).to receive(:loader_for).with(ref, any_args).and_return(loader)
|
|
end
|
|
end
|
|
end
|
|
end
|