mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
3101a4136b/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.
This commit is contained in:
parent
e3111c129a
commit
931120d37d
2 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue