aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorJack Nagel2013-01-22 14:33:33 -0600
committerJack Nagel2013-01-22 14:59:10 -0600
commit21efd0803cc1eae9912fdd12bd5ed440959c75ff (patch)
treef3a31dc287e631e9b97b47a064290de4e8af1607 /Library/Homebrew/test
parent0d28b0566d69fdd6e08026099009ada77632dd21 (diff)
downloadhomebrew-21efd0803cc1eae9912fdd12bd5ed440959c75ff.tar.bz2
Infer path to be added for requirements that search PATH
When a requirement is specified like: satisfy { which "foo" } There is no reason that we should inject all of ENV.userpaths! into the build environment. Instead, infer the directory to be added to PATH from the Pathname that is returned. This is another step towards condensing the "which program" requirements down into a one-liner DSL element.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_requirement.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb
index 0319e9e25..e8803ed92 100644
--- a/Library/Homebrew/test/test_requirement.rb
+++ b/Library/Homebrew/test/test_requirement.rb
@@ -74,4 +74,17 @@ class RequirementTests < Test::Unit::TestCase
assert req.satisfied?
end
+
+ def test_infers_path_from_satisfy_result
+ which_path = Pathname.new("/foo/bar/baz")
+ req = Class.new(Requirement) do
+ satisfy { which_path }
+ end.new
+
+ ENV.expects(:with_build_environment).yields.returns(which_path)
+ ENV.expects(:userpaths!)
+ ENV.expects(:append).with("PATH", which_path.parent, ":")
+
+ req.modify_build_environment
+ end
end