Does Rails 4.2 provide a single command that regenerates config/application.rb
in an existing application?
The reason I ask is imagine a Rails app is rails new
-ed without the --skip-test-unit
option.
Then at a much later date, this app is switched to RSpec. How can config/application.rb
be regenerated as if the --skip-test-unit
option had been supplied originally to rails new ...
?
All this would effectively do is change the require
statements near the top of config/application.rb
file from:
require 'rails/all'
to:
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
Delete the existing config/application.rb
and, in the directory above the project root, run rails new ...
with the options you want, including the application directory name, and the --skip-test-unit
option, and the --skip
option, which makes rails new ...
skip creating files that already exist:
# Inside your-rails-app/ directory:
# 1. Remove config/application.rb
rm config/application.rb
# 2. Move up one directory
cd ..
# 3. Regenerate rails application with the --skip
# option, using the name of your-rails-app. The
# --skip option will not generate files that
# already exist.
#
# This assumes you have rails installed as a global
# gem, of the version given in the command (version
# x.y.z in this case, replace with the version of Rails
# your app uses, e.g. 4.2.88):
rails _x.y.z_ new your-rails-app --skip --skip-test-unit
# 4. Run git status to see if any files were unexpectedly added
# (for example the README.rdoc file will be created
# if it did not exist).
git status
# 5. Clean up and commit the changes you want.
And that's it!