mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Add formula
spec helper.
This commit is contained in:
parent
9a0116d5c4
commit
004e8175c6
@ -16,6 +16,7 @@ require "tap"
|
|||||||
|
|
||||||
require "test/support/helper/shutup"
|
require "test/support/helper/shutup"
|
||||||
require "test/support/helper/fixtures"
|
require "test/support/helper/fixtures"
|
||||||
|
require "test/support/helper/formula"
|
||||||
require "test/support/helper/spec/shared_context/integration_test"
|
require "test/support/helper/spec/shared_context/integration_test"
|
||||||
|
|
||||||
TEST_DIRECTORIES = [
|
TEST_DIRECTORIES = [
|
||||||
@ -32,6 +33,7 @@ RSpec.configure do |config|
|
|||||||
config.order = :random
|
config.order = :random
|
||||||
config.include(Test::Helper::Shutup)
|
config.include(Test::Helper::Shutup)
|
||||||
config.include(Test::Helper::Fixtures)
|
config.include(Test::Helper::Fixtures)
|
||||||
|
config.include(Test::Helper::Formula)
|
||||||
config.before(:each) do |example|
|
config.before(:each) do |example|
|
||||||
if example.metadata[:needs_macos]
|
if example.metadata[:needs_macos]
|
||||||
skip "Not on macOS." unless OS.mac?
|
skip "Not on macOS." unless OS.mac?
|
||||||
|
19
Library/Homebrew/test/support/helper/formula.rb
Normal file
19
Library/Homebrew/test/support/helper/formula.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require "formulary"
|
||||||
|
|
||||||
|
module Test
|
||||||
|
module Helper
|
||||||
|
module Formula
|
||||||
|
def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block)
|
||||||
|
Class.new(::Formula, &block).new(name, path, spec, alias_path: alias_path)
|
||||||
|
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)
|
||||||
|
loader = double(get_formula: formula)
|
||||||
|
allow(Formulary).to receive(:loader_for).with(ref, from: :keg).and_return(loader)
|
||||||
|
allow(Formulary).to receive(:loader_for).with(ref, from: nil).and_return(loader)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user