diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-07-28 12:00:40 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-07-28 12:00:40 -0700 |
commit | f8c47aaab83f61dd25ec6ab25c4c63e503b53a10 (patch) | |
tree | 46b0b1d450942656b9c3c7a1eeb4e43fde9e0709 | |
parent | 75776a15d81f359197a669cae1b2ef051d613e24 (diff) | |
download | bundler-f8c47aaab83f61dd25ec6ab25c4c63e503b53a10.tar.gz |
Set the PATH and RUBYOPTS correctly in the environment files
-rw-r--r-- | lib/bundler/templates/environment.rb | 3 | ||||
-rw-r--r-- | spec/bundler/cli_spec.rb | 26 |
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/bundler/templates/environment.rb b/lib/bundler/templates/environment.rb index d51628a15d..005a2eb34e 100644 --- a/lib/bundler/templates/environment.rb +++ b/lib/bundler/templates/environment.rb @@ -6,6 +6,9 @@ module Bundler end end +ENV["PATH"] = "<%= @bindir %>:#{ENV["PATH"]}" +ENV["RUBYOPT"] = "-r#{__FILE__} #{ENV["RUBYOPT"]}" + <% if @rubygems == :optional %> $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__)) <% end %> diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index dabd24a8d1..3195e0a8c8 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -8,6 +8,7 @@ describe "Bundler::CLI" do source "file://#{gem_repo1}" gem "rake" gem "extlib" + gem "very-simple" gem "rack", :only => :web Gemfile @@ -20,7 +21,7 @@ describe "Bundler::CLI" do end it "caches and installs rake" do - gems = %w(rake-0.8.7 extlib-0.9.12 rack-0.9.1) + gems = %w(rake-0.8.7 extlib-0.9.12 rack-0.9.1 very-simple-1.0) tmp_file("vendor", "gems").should have_cached_gems(*gems) tmp_file("vendor", "gems").should have_installed_gems(*gems) end @@ -28,13 +29,15 @@ describe "Bundler::CLI" do it "creates a default environment file with the appropriate load paths" do tmp_file('vendor', 'gems', 'environments', 'default.rb').should have_load_paths(tmp_file("vendor", "gems"), "extlib-0.9.12" => %w(lib), - "rake-0.8.7" => %w(bin lib) + "rake-0.8.7" => %w(bin lib), + "very-simple-1.0" => %w(bin lib) ) tmp_file('vendor', 'gems', 'environments', 'web.rb').should have_load_paths(tmp_file("vendor", "gems"), "extlib-0.9.12" => %w(lib), "rake-0.8.7" => %w(bin lib), - "rack-0.9.1" => %w(bin lib) + "rack-0.9.1" => %w(bin lib), + "very-simple-1.0" => %w(bin lib) ) end @@ -43,18 +46,35 @@ describe "Bundler::CLI" do out.should include(tmp_file("vendor", "gems", "gems", "rake-0.8.7", "lib").to_s) out.should include(tmp_file("vendor", "gems", "gems", "rake-0.8.7", "bin").to_s) out.should include(tmp_file("vendor", "gems", "gems", "extlib-0.9.12", "lib").to_s) + out.should include(tmp_file("vendor", "gems", "gems", "very-simple-1.0", "lib").to_s) out.should_not include(tmp_file("vendor", "gems", "gems", "rack-0.9.1").to_s) end + it "maintains the correct environment when shelling out" do + File.open(tmp_file("Rakefile"), 'w') do |f| + f.puts <<-RAKE +task :hello do + exec %{#{Gem.ruby} -e 'require "very-simple" ; puts VerySimpleForTests'} +end + RAKE + end + Dir.chdir(tmp_dir) do + out = `#{tmp_file("bin", "rake")} hello` + out.should == "VerySimpleForTests\n" + end + end + it "logs the correct information messages" do [ "Updating source: file:#{gem_repo1}", "Calculating dependencies...", "Downloading rake-0.8.7.gem", "Downloading extlib-0.9.12.gem", "Downloading rack-0.9.1.gem", + "Downloading very-simple-1.0.gem", "Installing rake-0.8.7.gem", "Installing extlib-0.9.12.gem", "Installing rack-0.9.1.gem", + "Installing very-simple-1.0.gem", "Done." ].each do |message| @output.should =~ /^#{Regexp.escape(message)}$/ end |