From 62fa173bd9117cf2bc93c01984b8decfcc78accb Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 16 May 2012 04:46:26 -0700 Subject: Don't use Gemfile in test application in railties Option to run `bundle install` after generating new appplication was added recently to rails. Since introduction, it contained a subtle bug that caused it to use `Gemfile` from current directory (if it exists) rather than from generated directory. This also accidentaly caused railties tests to work without any problems - after generating test app it just used `Gemfile` from the repository, rather than the one in generated app. After fixing the bug mentioned above, this of course broke. The easiest way to bypass that is to not generate a `Gemfile` for test application - with such setup Bundler will just use first available `Gemfile` in one of the parent directories. --- railties/test/isolation/abstract_unit.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 37839a1c54..07a7faa3af 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -8,7 +8,7 @@ # Rails booted up. require 'fileutils' -require 'bundler/setup' +require 'bundler/setup' unless defined?(Bundler) require 'minitest/autorun' require 'active_support/test_case' @@ -105,8 +105,9 @@ module TestHelpers end end - unless options[:gemfile] - File.delete"#{app_path}/Gemfile" + gemfile_path = "#{app_path}/Gemfile" + if options[:gemfile].blank? && File.exist?(gemfile_path) + File.delete gemfile_path end routes = File.read("#{app_path}/config/routes.rb") @@ -281,8 +282,7 @@ Module.new do environment = File.expand_path('../../../../load_paths', __FILE__) require_environment = "-r #{environment}" - `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails new #{app_template_path}` - + `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails new #{app_template_path} --skip-gemfile` File.open("#{app_template_path}/config/boot.rb", 'w') do |f| f.puts "require '#{environment}'" f.puts "require 'rails/all'" -- cgit v1.2.3