diff options
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index d2818eeaf1..0f73c43e0c 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -492,6 +492,12 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_generator_if_yarn_option_is_given + run_generator([destination_root, "--yarn"]) + assert_file "package.json", /dependencies/ + assert_file "config/initializers/assets.rb", /node_modules/ + end + def test_inclusion_of_jbuilder run_generator assert_gem "jbuilder" @@ -612,6 +618,10 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_generates_with_bundler end + def test_generation_runs_yarn_install_with_yarn_option + assert_generates_with_yarn yarn: true + end + def test_dev_option assert_generates_with_bundler dev: true rails_path = File.expand_path("../../..", Rails.root) @@ -837,4 +847,18 @@ class AppGeneratorTest < Rails::Generators::TestCase quietly { generator.invoke_all } end end + + def assert_generates_with_yarn(options = {}) + generator([destination_root], options) + + command_check = -> command do + @install_called ||= 0 + @install_called += 1 + assert_equal 1, @install_called, "install expected to be called once, but was called #{@install_called} times" + end + + generator.stub :yarn_command, command_check do + quietly { generator.invoke_all } + end + end end |