From 71f85300b4da4a1e3bd161646a7cd91fb1436734 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 12 Feb 2013 16:24:30 -0600 Subject: Establish a convention for Requirement names The name attribute of requirements is used when generating options for the :optional and :recommended dependency tags. Unless otherwise specified, the name attribute of a Requirement will be populated by stripping any module prefixes from the beginning and "Dependency" or "Requirement" from end of the class name and downcasing the result. Closes Homebrew/homebrew#17759. --- Library/Homebrew/test/test_requirement.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb index ed7c37706..682ee432e 100644 --- a/Library/Homebrew/test/test_requirement.rb +++ b/Library/Homebrew/test/test_requirement.rb @@ -92,4 +92,12 @@ class RequirementTests < Test::Unit::TestCase req = Class.new(Requirement) { build true }.new assert req.build? end + + def test_infer_name_from_class + klass, const = self.class, :FooRequirement + klass.const_set(const, Class.new(Requirement)) + assert_equal "foo", klass.const_get(const).new.name + ensure + klass.send(:remove_const, const) if klass.const_defined?(const) + end end -- cgit v1.2.3