Browse files

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.
  • Loading branch information...
1 parent 94dc881 commit 6218c3723c4f3c659a9f2ad164f90283a5400652 @drogus drogus committed May 16, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 railties/test/isolation/abstract_unit.rb
9 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'
@@ -104,8 +104,9 @@ def build_app(options = {})
- 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
routes ="#{app_path}/config/routes.rb")
@@ -282,7 +283,7 @@ class ActiveSupport::TestCase
require_environment = "-r #{environment}"
- `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails new #{tmp_path('app_template')}`
+ `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails new #{tmp_path('app_template')} --skip-gemfile`"#{tmp_path}/app_template/config/boot.rb", 'w') do |f|
if require_environment
f.puts "Dir.chdir('#{File.dirname(environment)}') do"

0 comments on commit 6218c37

Please sign in to comment.