From 1a1f319cd498ee926aa7b0e3481b213de59be041 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Sun, 13 Aug 2017 23:12:07 +0300 Subject: Add --skip-yarn option to the plugin generator Add SharedGeneratorTests#application_path This method will help to DRY in files app_generator_test.rb, plugin_generator_test.rb --- railties/test/generators/shared_generator_tests.rb | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'railties/test/generators/shared_generator_tests.rb') diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index c73b91e3f8..6c0775b50e 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -22,6 +22,10 @@ module SharedGeneratorTests Rails.application = TestApp::Application.instance end + def application_path + destination_root + end + def test_skeleton_is_created run_generator @@ -123,4 +127,30 @@ module SharedGeneratorTests assert_no_file("app/models/concerns/.keep") end + + def test_generator_for_yarn + run_generator + assert_file "#{application_path}/package.json", /dependencies/ + assert_file "#{application_path}/config/initializers/assets.rb", /node_modules/ + + assert_file ".gitignore" do |content| + assert_match(/node_modules/, content) + assert_match(/yarn-error\.log/, content) + end + end + + def test_generator_for_yarn_skipped + run_generator([destination_root, "--skip-yarn"]) + assert_no_file "#{application_path}/package.json" + assert_no_file "#{application_path}/bin/yarn" + + assert_file "#{application_path}/config/initializers/assets.rb" do |content| + assert_no_match(/node_modules/, content) + end + + assert_file ".gitignore" do |content| + assert_no_match(/node_modules/, content) + assert_no_match(/yarn-error\.log/, content) + end + end end -- cgit v1.2.3