diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2016-11-29 10:04:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-29 10:04:47 -0500 |
commit | 43e42ad385f1048e6ec7a9df6c83daa5ef003870 (patch) | |
tree | ee63a13fccf9318a12ea6b513d103ba6abd26139 /railties/test | |
parent | ffb81ad6e3326332556e8eab867fe1a27a989bf5 (diff) | |
parent | 9a95e13989380e59245d3d6fb0853953b806742c (diff) | |
download | rails-43e42ad385f1048e6ec7a9df6c83daa5ef003870.tar.gz rails-43e42ad385f1048e6ec7a9df6c83daa5ef003870.tar.bz2 rails-43e42ad385f1048e6ec7a9df6c83daa5ef003870.zip |
Merge pull request #26836 from Liceth/npm
Add Yarn support in new apps using --yarn option
Diffstat (limited to 'railties/test')
-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 |