aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md5
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb1
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/spring.rb6
-rw-r--r--railties/lib/rails/tasks/framework.rake4
-rw-r--r--railties/test/application/integration_test_case_test.rb2
-rw-r--r--railties/test/generators/actions_test.rb18
-rw-r--r--railties/test/generators/app_generator_test.rb4
-rw-r--r--railties/test/generators/channel_generator_test.rb16
8 files changed, 35 insertions, 21 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index f3da431b09..fa764ef02d 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,8 @@
+* The application generator writes a new file `config/spring.rb`, which tells
+ Spring to watch additional common files.
+
+ *Xavier Noria*
+
* The tasks in the rails task namespace is deprecated in favor of app namespace.
(e.g. `rails:update` and `rails:template` tasks is renamed to `app:update` and `app:template`.)
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 7bab3fdf74..562193bc3a 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -80,6 +80,7 @@ module Rails
template "secrets.yml"
template "cable.yml" unless options[:skip_action_cable]
template "puma.rb" unless options[:skip_puma]
+ template "spring.rb" if spring_install?
directory "environments"
directory "initializers"
diff --git a/railties/lib/rails/generators/rails/app/templates/config/spring.rb b/railties/lib/rails/generators/rails/app/templates/config/spring.rb
new file mode 100644
index 0000000000..c9119b40c0
--- /dev/null
+++ b/railties/lib/rails/generators/rails/app/templates/config/spring.rb
@@ -0,0 +1,6 @@
+%w(
+ .ruby-version
+ .rbenv-vars
+ tmp/restart.txt
+ tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake
index ae92836407..bf25b74627 100644
--- a/railties/lib/rails/tasks/framework.rake
+++ b/railties/lib/rails/tasks/framework.rake
@@ -73,8 +73,8 @@ namespace :rails do
%i(update template templates:copy update:configs update:bin).each do |task_name|
task "#{task_name}" do
ActiveSupport::Deprecation.warn(<<-MSG.squish)
- Running #{task_name} with the rails: namespace is deprecated in favor of app.
- Run e.g. bin/rails app:#{task_name} instead."
+ Running #{task_name} with the rails: namespace is deprecated in favor of app: namespace.
+ Run bin/rails app:#{task_name} instead.
MSG
Rake.application.invoke_task("app:#{task_name}")
end
diff --git a/railties/test/application/integration_test_case_test.rb b/railties/test/application/integration_test_case_test.rb
index 40a79fc636..d106d5159a 100644
--- a/railties/test/application/integration_test_case_test.rb
+++ b/railties/test/application/integration_test_case_test.rb
@@ -40,7 +40,7 @@ module ApplicationTests
output = Dir.chdir(app_path) { `bin/rails test 2>&1` }
assert_equal 0, $?.to_i, output
- assert_match /0 failures, 0 errors/, output
+ assert_match(/0 failures, 0 errors/, output)
end
end
end
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 6158748194..58394a11f0 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -201,7 +201,7 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_rake_should_run_rake_command_with_default_env
+ def test_rails_should_run_rake_command_with_default_env
assert_called_with(generator, :run, ["rails log:clear RAILS_ENV=development", verbose: false]) do
with_rails_env nil do
action :rake, 'log:clear'
@@ -209,13 +209,13 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_rake_with_env_option_should_run_rake_command_in_env
+ def test_rails_with_env_option_should_run_rake_command_in_env
assert_called_with(generator, :run, ['rails log:clear RAILS_ENV=production', verbose: false]) do
action :rake, 'log:clear', env: 'production'
end
end
- def test_rake_with_rails_env_variable_should_run_rake_command_in_env
+ test "rails command with RAILS_ENV variable should run rake command in env" do
assert_called_with(generator, :run, ['rails log:clear RAILS_ENV=production', verbose: false]) do
with_rails_env "production" do
action :rake, 'log:clear'
@@ -223,7 +223,7 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_env_option_should_win_over_rails_env_variable_when_running_rake
+ test "env option should win over RAILS_ENV variable when running rake" do
assert_called_with(generator, :run, ['rails log:clear RAILS_ENV=production', verbose: false]) do
with_rails_env "staging" do
action :rake, 'log:clear', env: 'production'
@@ -231,7 +231,7 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_rake_with_sudo_option_should_run_rake_command_with_sudo
+ test "rails command with sudo option should run rake command with sudo" do
assert_called_with(generator, :run, ["sudo rails log:clear RAILS_ENV=development", verbose: false]) do
with_rails_env nil do
action :rake, 'log:clear', sudo: true
@@ -239,7 +239,7 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_rails_command_should_run_rails_command_with_default_env
+ test "rails command should run rails_command with default env" do
assert_called_with(generator, :run, ["rails log:clear RAILS_ENV=development", verbose: false]) do
with_rails_env nil do
action :rails_command, 'log:clear'
@@ -247,13 +247,13 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_rails_command_with_env_option_should_run_rails_command_in_env
+ test "rails command with env option should run rails_command with same env" do
assert_called_with(generator, :run, ['rails log:clear RAILS_ENV=production', verbose: false]) do
action :rails_command, 'log:clear', env: 'production'
end
end
- def test_rails_command_with_rails_env_variable_should_run_rails_command_in_env
+ test "rails command with RAILS_ENV variable should run rails_command in env" do
assert_called_with(generator, :run, ['rails log:clear RAILS_ENV=production', verbose: false]) do
with_rails_env "production" do
action :rails_command, 'log:clear'
@@ -269,7 +269,7 @@ class ActionsTest < Rails::Generators::TestCase
end
end
- def test_rails_command_with_sudo_option_should_run_rails_command_with_sudo
+ test "rails command with sudo option should run rails_command with sudo" do
assert_called_with(generator, :run, ["sudo rails log:clear RAILS_ENV=development", verbose: false]) do
with_rails_env nil do
action :rails_command, 'log:clear', sudo: true
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 63655044da..20b2cd3cca 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -28,6 +28,7 @@ DEFAULT_APP_FILES = %w(
config/locales
config/cable.yml
config/puma.rb
+ config/spring.rb
db
lib
lib/tasks
@@ -669,7 +670,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_spring_no_fork
jruby_skip "spring doesn't run on JRuby"
- assert_called_with(Process, :respond_to?, [:fork], returns: false) do
+ assert_called_with(Process, :respond_to?, [[:fork], [:fork]], returns: false) do
run_generator
assert_file "Gemfile" do |content|
@@ -681,6 +682,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_skip_spring
run_generator [destination_root, "--skip-spring"]
+ assert_no_file 'config/spring.rb'
assert_file "Gemfile" do |content|
assert_no_match(/spring/, content)
end
diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb
index e31736a74c..cda9e8b910 100644
--- a/railties/test/generators/channel_generator_test.rb
+++ b/railties/test/generators/channel_generator_test.rb
@@ -6,16 +6,16 @@ class ChannelGeneratorTest < Rails::Generators::TestCase
tests Rails::Generators::ChannelGenerator
def test_application_cable_skeleton_is_created
- run_generator ['books']
+ run_generator ['books']
- assert_file "app/channels/application_cable/channel.rb" do |cable|
- assert_match(/module ApplicationCable\n class Channel < ActionCable::Channel::Base\n/, cable)
- end
+ assert_file "app/channels/application_cable/channel.rb" do |cable|
+ assert_match(/module ApplicationCable\n class Channel < ActionCable::Channel::Base\n/, cable)
+ end
- assert_file "app/channels/application_cable/connection.rb" do |cable|
- assert_match(/module ApplicationCable\n class Connection < ActionCable::Connection::Base\n/, cable)
- end
- end
+ assert_file "app/channels/application_cable/connection.rb" do |cable|
+ assert_match(/module ApplicationCable\n class Connection < ActionCable::Connection::Base\n/, cable)
+ end
+ end
def test_channel_is_created
run_generator ['chat']