Skip to content

Commit

Permalink
In app_generator, fix hardcoded bundle call to derive the bundle ex…
Browse files Browse the repository at this point in the history
…ecutable name from Thor::Util.ruby_command.

This ensures that eg. when `rails` is called from `ruby1.9`, `bundle1.9` is called.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
kch authored and josevalim committed Mar 12, 2010
1 parent 9268b59 commit 94a60a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion railties/lib/generators/rails/app/app_generator.rb
Expand Up @@ -178,7 +178,8 @@ def apply_rails_template
end

def bundle_if_dev_or_edge
run "bundle install" if dev_or_edge?
bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
run "#{bundle_command} install" if dev_or_edge?
end

protected
Expand Down
5 changes: 3 additions & 2 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -9,6 +9,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def setup
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
@bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
end

def teardown
Expand Down Expand Up @@ -168,14 +169,14 @@ def test_file_is_added_for_backwards_compatibility
end

def test_dev_option
generator([destination_root], :dev => true).expects(:run).with("bundle install")
generator([destination_root], :dev => true).expects(:run).with("#{@bundle_command} install")
silence(:stdout){ generator.invoke }
rails_path = File.expand_path('../../..', Rails.root)
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/
end

def test_edge_option
generator([destination_root], :edge => true).expects(:run).with("bundle install")
generator([destination_root], :edge => true).expects(:run).with("#{@bundle_command} install")
silence(:stdout){ generator.invoke }
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$/
end
Expand Down

0 comments on commit 94a60a5

Please sign in to comment.