Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add `--skip-yarn` option to the plugin generator #30238

Merged

Conversation

@bogdanvlviv
Copy link
Contributor

@bogdanvlviv bogdanvlviv commented Aug 13, 2017

No description provided.

@rails-bot
Copy link

@rails-bot rails-bot commented Aug 13, 2017

r? @sgrif

(@rails-bot has picked a reviewer for you, use r? to override)

railties/test/generators/plugin_generator_test.rb Outdated
@@ -148,6 +148,32 @@ def test_generating_adds_dummy_app_without_sprockets
end
end

def test_generator_for_yarn

This comment has been minimized.

@y-yagi

y-yagi Aug 13, 2017
Member

Rather than adding a test to PluginGeneratorTest, how about moving the test at AppGeneratorTest to SharedGeneratorTests?

This comment has been minimized.

This comment has been minimized.

@bogdanvlviv

bogdanvlviv Aug 15, 2017
Author Contributor

The test test_generator_for_yarn in railties/test/generators/app_generator_test.rb different from test_generator_for_yarn in railties/test/generators/plugin_generator_test.rb

Expample:

assert_file "package.json", /dependencies/ #  railties/test/generators/app_generator_test.rb
assert_file "test/dummy/package.json", /dependencies/ # railties/test/generators/plugin_generator_test.rb

This comment has been minimized.

@y-yagi

y-yagi Aug 15, 2017
Member

How about letting specify the application path from each test? As described below.

diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index ccb437c..cb46000 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
+
+    def application_path
+      destination_root
+    end
 end
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index bd76af8..f55b89a 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -150,6 +150,18 @@ def test_generating_adds_dummy_app_without_sprockets
     end
   end
 
+  private
+    def application_path
+      "#{destination_root}/test/dummy"
+    end
 end
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index c73b91e..d584fbb 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -114,6 +114,13 @@ def test_skip_git
     assert_no_directory(".git")
   end
 
+  def test_generator_for_yarn
+    run_generator([destination_root])
+
+    assert_file "#{application_path}/package.json", /dependencies/
+    assert_file "#{application_path}/config/initializers/assets.rb", /node_modules/
+  end

This comment has been minimized.

@bogdanvlviv

bogdanvlviv Aug 15, 2017
Author Contributor

@y-yagi I've just implemented it.
Itl definitely will help me to do more dryer tests in this PR: #30101.
Also, I've have prepared new changes to dry tests in railties/test/generators/app_generator_test.rb and railties/test/generators/plugin_generator_test.rb.
When it merges, I will open new PR with this changes.

Thank you!

railties/test/generators/plugin_generator_test.rb Outdated
@@ -148,6 +148,32 @@ def test_generating_adds_dummy_app_without_sprockets
end
end

def test_generator_for_yarn

This comment has been minimized.

@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:add-skip_yarn-for-plugin_generator branch Aug 15, 2017
@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Aug 15, 2017

Could you squash your commits?

Add SharedGeneratorTests#application_path
This method will help to DRY in files app_generator_test.rb, plugin_generator_test.rb
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:add-skip_yarn-for-plugin_generator branch to 1a1f319 Aug 15, 2017
@bogdanvlviv
Copy link
Contributor Author

@bogdanvlviv bogdanvlviv commented Aug 15, 2017

Done!

@rafaelfranca rafaelfranca merged commit 692fab2 into rails:master Aug 15, 2017
2 checks passed
2 checks passed
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bogdanvlviv bogdanvlviv deleted the bogdanvlviv:add-skip_yarn-for-plugin_generator branch Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.