Fix protection against overriding Formula#brew
The test for this previously passed, but only because the constructor for SoftwareSpecification was raising an exception. method_added needs to be a class method because methods are being defined on the class, not the object, and to test it properly we have to eval the class in the test itself. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
04bf4e5f89
commit
9614301be4
@ -551,8 +551,8 @@ private
|
||||
instance_variable_set("@#{type}", class_value) if class_value
|
||||
end
|
||||
|
||||
def method_added method
|
||||
raise 'You cannot override Formula.brew' if method == 'brew'
|
||||
def self.method_added method
|
||||
raise 'You cannot override Formula.brew' if method == :brew
|
||||
end
|
||||
|
||||
class << self
|
||||
|
||||
@ -19,15 +19,6 @@ class MostlyAbstractFormula <Formula
|
||||
@homepage = 'http://example.com/'
|
||||
end
|
||||
|
||||
class TestBallOverrideBrew <Formula
|
||||
def initialize
|
||||
super "foo"
|
||||
end
|
||||
def brew
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class FormulaTests < Test::Unit::TestCase
|
||||
|
||||
def test_prefix
|
||||
@ -48,7 +39,17 @@ class FormulaTests < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_cant_override_brew
|
||||
assert_raises(RuntimeError) { TestBallOverrideBrew.new }
|
||||
assert_raises(RuntimeError) do
|
||||
eval <<-EOS
|
||||
class TestBallOverrideBrew <Formula
|
||||
def initialize
|
||||
super "foo"
|
||||
end
|
||||
def brew
|
||||
end
|
||||
end
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def test_abstract_formula
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user