Raise an exception when double loading a formula
(As proposed in #2673)
This commit is contained in:
parent
d6d681ca01
commit
4760f4e803
@ -20,6 +20,8 @@ module Formulary
|
|||||||
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!"
|
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
raise "Formula #{name} has already been loaded" if const_defined?(namespace)
|
||||||
|
|
||||||
mod = Module.new
|
mod = Module.new
|
||||||
const_set(namespace, mod)
|
const_set(namespace, mod)
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -27,6 +27,16 @@ describe Formulary do
|
|||||||
let(:bottle_dir) { Pathname.new("#{TEST_FIXTURE_DIR}/bottles") }
|
let(:bottle_dir) { Pathname.new("#{TEST_FIXTURE_DIR}/bottles") }
|
||||||
let(:bottle) { bottle_dir/"testball_bottle-0.1.#{Utils::Bottles.tag}.bottle.tar.gz" }
|
let(:bottle) { bottle_dir/"testball_bottle-0.1.#{Utils::Bottles.tag}.bottle.tar.gz" }
|
||||||
|
|
||||||
|
describe "::load_formula" do
|
||||||
|
it "does not allow namespace repetition" do |example|
|
||||||
|
definition = "Foo = Class.new(Formula)"
|
||||||
|
namespace = "Test#{example.description.hash.abs}"
|
||||||
|
subject.load_formula("foo", "bar", definition, namespace)
|
||||||
|
expect { subject.load_formula("foo", "bar", definition, namespace) }
|
||||||
|
.to raise_error RuntimeError, /already.* loaded/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "::class_s" do
|
describe "::class_s" do
|
||||||
it "replaces '+' with 'x'" do
|
it "replaces '+' with 'x'" do
|
||||||
expect(subject.class_s("foo++")).to eq("Fooxx")
|
expect(subject.class_s("foo++")).to eq("Fooxx")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user