Permalink
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...
drogus committed May 16, 2012
1 parent 7fc4b46 commit 62fa173bd9117cf2bc93c01984b8decfcc78accb
Showing with 5 additions and 5 deletions.
  1. +5 −5 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 @@ def build_app(options = {})
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 @@ class ActiveSupport::TestCase
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'"

0 comments on commit 62fa173

Please sign in to comment.