From 9614301be4f2647de6a0395b125c3a2ca69e3889 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 6 Apr 2012 17:28:44 -0500 Subject: [PATCH] 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 --- Library/Homebrew/formula.rb | 4 ++-- Library/Homebrew/test/test_formula.rb | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 82788869ed..cecb904ab1 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 27761e2893..ef3e0952b7 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -19,15 +19,6 @@ class MostlyAbstractFormula