diff options
author | Terence Lee <hone02@gmail.com> | 2012-04-22 11:18:32 -0500 |
---|---|---|
committer | Terence Lee <hone02@gmail.com> | 2012-05-03 16:26:04 -0700 |
commit | ce22fed8098d61ba9ae0679f3d7894b0eb24c478 (patch) | |
tree | f44cab2a9f93e90eea28d74da3a5b1b0d27b0304 | |
parent | c30248257eb213578943cff58e1182ee1717eae7 (diff) | |
download | bundler-ce22fed8098d61ba9ae0679f3d7894b0eb24c478.tar.gz |
ruby version check for bundle#exec
-rw-r--r-- | lib/bundler/cli.rb | 1 | ||||
-rw-r--r-- | spec/other/ruby_spec.rb | 58 |
2 files changed, 56 insertions, 3 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 0ecad44b..4eab7ac6 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -415,6 +415,7 @@ module Bundler def exec(*) ARGV.shift # remove "exec" + Bundler.definition.validate_ruby! Bundler.load.setup_environment begin diff --git a/spec/other/ruby_spec.rb b/spec/other/ruby_spec.rb index ef3237a9..86a5fe8e 100644 --- a/spec/other/ruby_spec.rb +++ b/spec/other/ruby_spec.rb @@ -99,17 +99,17 @@ describe "bundle ruby" do def should_be_ruby_version_incorrect exitstatus.should eq(18) - out.should == "Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}" + out.should be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}") end def should_be_engine_incorrect exitstatus.should eq(18) - out.should == "Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}" + out.should be_include("Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}") end def should_be_engine_version_incorrect exitstatus.should eq(18) - out.should == "Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}" + out.should be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}") end context "bundle install" do @@ -484,4 +484,56 @@ describe "bundle ruby" do end end end + + context "bundle exec" do + before do + system_gems "rack-1.0.0", "rack-0.9.1" + end + + it "activates the correct gem when ruby version matches" do + gemfile <<-G + gem "rack", "0.9.1" + + #{ruby_version_correct} + G + + bundle "exec rackup" + out.should == "0.9.1" + end + + it "fails when the ruby version doesn't match" do + gemfile <<-G + gem "rack", "0.9.1" + + #{ruby_version_incorrect} + G + + bundle "exec rackup", :exitstatus => true + should_be_ruby_version_incorrect + end + + it "fails when the engine doesn't match" do + gemfile <<-G + gem "rack", "0.9.1" + + #{engine_incorrect} + G + + bundle "exec rackup", :exitstatus => true + should_be_engine_incorrect + end + + it "fails when the engine version doesn't match" do + simulate_ruby_engine "jruby" do + gemfile <<-G + gem "rack", "0.9.1" + + #{engine_version_incorrect} + G + + bundle "exec rackup", :exitstatus => true + should_be_engine_version_incorrect + end + end + end end |