diff options
| author | Markus Reiter | 2017-02-25 13:26:50 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-02-25 13:26:50 +0100 |
| commit | 004e8175c6ceb58f026e79e6bbd0ddac9e8380f6 (patch) | |
| tree | 0afee0e19787098c93becf702610e8f787a83ef8 /Library/Homebrew/test/support | |
| parent | 9a0116d5c4967441a6c85656ef7f15795cd02bbc (diff) | |
| download | brew-004e8175c6ceb58f026e79e6bbd0ddac9e8380f6.tar.bz2 | |
Add `formula` spec helper.
Diffstat (limited to 'Library/Homebrew/test/support')
| -rw-r--r-- | Library/Homebrew/test/support/helper/formula.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Library/Homebrew/test/support/helper/formula.rb b/Library/Homebrew/test/support/helper/formula.rb new file mode 100644 index 000000000..7f55f4b66 --- /dev/null +++ b/Library/Homebrew/test/support/helper/formula.rb @@ -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 |
