diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb index adf36c4d94..c60bd36860 100644 --- a/Library/Homebrew/dependencies.rb +++ b/Library/Homebrew/dependencies.rb @@ -224,7 +224,6 @@ class Requirement def satisfy(options={}, &block) if block_given? - options[:userpaths] = true if env.userpaths? @satisfied ||= Requirement::Satisfier.new(options, &block) else @satisfied ||= options @@ -243,7 +242,7 @@ class Requirement if @options[:build_env] require 'superenv' ENV.with_build_environment do - ENV.userpaths! if @options[:userpaths] + ENV.userpaths! yield @proc end else diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb index 0f1cc02deb..0319e9e252 100644 --- a/Library/Homebrew/test/test_requirement.rb +++ b/Library/Homebrew/test/test_requirement.rb @@ -45,29 +45,33 @@ class RequirementTests < Test::Unit::TestCase assert !req.satisfied? end - def test_satisfy_with_userpaths_from_env - ENV.expects(:with_build_environment).yields.returns(true) - ENV.expects(:userpaths!) - req = Class.new(Requirement) do - env :userpaths - satisfy(:build_env => true) { true } - end.new - assert req.satisfied? - end - - def test_satisfy_with_userpaths_from_options - ENV.expects(:with_build_environment).yields.returns(true) - ENV.expects(:userpaths!) - req = Class.new(Requirement) do - satisfy(:build_env => true, :userpaths => true) { true } - end.new - assert req.satisfied? - end - def test_satisfy_with_boolean req = Class.new(Requirement) do satisfy true end.new assert req.satisfied? end + + def test_satisfy_sets_up_build_env_by_default + req = Class.new(Requirement) do + env :userpaths + satisfy { true } + end.new + + ENV.expects(:with_build_environment).yields.returns(true) + ENV.expects(:userpaths!) + + assert req.satisfied? + end + + def test_satisfy_build_env_can_be_disabled + req = Class.new(Requirement) do + satisfy(:build_env => false) { true } + end.new + + ENV.expects(:with_build_environment).never + ENV.expects(:userpaths!).never + + assert req.satisfied? + end end