aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-10-20 14:16:29 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-10-20 14:41:51 +0900
commit931120d37d8f204f0e8c2aabbe4caa68347ee7b9 (patch)
tree89d4d64f051552dc5af6c699b72bda303ce3939e /railties
parente3111c129a557bee8691c34acc209d0727418957 (diff)
downloadrails-931120d37d8f204f0e8c2aabbe4caa68347ee7b9.tar.gz
rails-931120d37d8f204f0e8c2aabbe4caa68347ee7b9.tar.bz2
rails-931120d37d8f204f0e8c2aabbe4caa68347ee7b9.zip
Avoid running `webpacker:install` on tests that don't need it
If use `run_generator` to run the generator, `--skip-webpack-install` is specified automatically. https://github.com/rails/rails/blob/3101a4136bd62787e252d2658eee23001036fa0f/railties/lib/rails/generators/testing/behaviour.rb#L71 However, when executing the generator independently (for example, to use stub), `webpacker:install` was executed. Since this includes `yarn install`, it should be avoided in unnecessary testing.
Diffstat (limited to 'railties')
-rw-r--r--railties/test/generators/app_generator_test.rb12
-rw-r--r--railties/test/generators/shared_generator_tests.rb4
2 files changed, 10 insertions, 6 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index e47d180809..e282c82faf 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -104,7 +104,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_skip_bundle
- assert_not_called(generator([destination_root], skip_bundle: true), :bundle_command) do
+ assert_not_called(generator([destination_root], skip_bundle: true, skip_webpack_install: true), :bundle_command) do
quietly { generator.invoke_all }
# skip_bundle is only about running bundle install, ensure the Gemfile is still
# generated.
@@ -728,13 +728,13 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_generation_runs_bundle_install
- generator([destination_root], {})
+ generator([destination_root], skip_webpack_install: true)
assert_bundler_command_called("install")
end
def test_dev_option
- generator([destination_root], dev: true)
+ generator([destination_root], dev: true, skip_webpack_install: true)
assert_bundler_command_called("install")
rails_path = File.expand_path("../../..", Rails.root)
@@ -742,7 +742,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_edge_option
- generator([destination_root], edge: true)
+ generator([destination_root], edge: true, skip_webpack_install: true)
assert_bundler_command_called("install")
assert_file "Gemfile", %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$}
@@ -754,12 +754,16 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_bundler_binstub
+ generator([destination_root], skip_webpack_install: true)
+
assert_bundler_command_called("binstubs bundler")
end
def test_spring_binstubs
jruby_skip "spring doesn't run on JRuby"
+ generator([destination_root], skip_webpack_install: true)
+
assert_bundler_command_called("exec spring binstub --all")
end
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index fc654e867b..d61545a7b5 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -91,7 +91,7 @@ module SharedGeneratorTests
template
end
- generator([destination_root], template: path).stub(:open, check_open, template) do
+ generator([destination_root], template: path, skip_webpack_install: true).stub(:open, check_open, template) do
generator.stub :bundle_command, nil do
quietly { assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) }
end
@@ -99,7 +99,7 @@ module SharedGeneratorTests
end
def test_skip_gemfile
- assert_not_called(generator([destination_root], skip_gemfile: true), :bundle_command) do
+ assert_not_called(generator([destination_root], skip_gemfile: true, skip_webpack_install: true), :bundle_command) do
quietly { generator.invoke_all }
assert_no_file "Gemfile"
end