aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_requirement.rb
diff options
context:
space:
mode:
authorJack Nagel2013-02-12 16:24:30 -0600
committerJack Nagel2013-02-12 16:26:10 -0600
commit71f85300b4da4a1e3bd161646a7cd91fb1436734 (patch)
treebcd4aae0d25cb2e6b7f066915c889717e58d9ba9 /Library/Homebrew/test/test_requirement.rb
parentd71c8beac9d2d173fceb24cb0dd316c943e72c3b (diff)
downloadbrew-71f85300b4da4a1e3bd161646a7cd91fb1436734.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew/test/test_requirement.rb')
-rw-r--r--Library/Homebrew/test/test_requirement.rb8
1 files changed, 8 insertions, 0 deletions
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