aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2017-12-05 14:32:14 -0500
committerGitHub <noreply@github.com>2017-12-05 14:32:14 -0500
commit12fa2ea5dcf2aa0ac35ab5f0e6cac9d673f282c3 (patch)
tree30eafcfc4c69e63e64783ab558268804d4c14c7b /railties/test/generators
parent7efb4d23c1022108319add6218ae9d9284936ac5 (diff)
parent6a11b0c1549e88a7ca32a73764d8b6634dc326e2 (diff)
downloadrails-12fa2ea5dcf2aa0ac35ab5f0e6cac9d673f282c3.tar.gz
rails-12fa2ea5dcf2aa0ac35ab5f0e6cac9d673f282c3.tar.bz2
rails-12fa2ea5dcf2aa0ac35ab5f0e6cac9d673f282c3.zip
Merge pull request #31335 from ttanimichi/more-tests-for-webpack-option
Add more tests for the `--webpack` option
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/app_generator_test.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index decea77d48..96803db838 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -746,17 +746,38 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_webpack_option
command_check = -> command, *_ do
@called ||= 0
- @called += 1 if command == "webpacker:install"
- assert_equal 1, @called, "webpacker:install expected to be called once, but was called #{@called} times."
+ if command == "webpacker:install"
+ @called += 1
+ assert_equal 1, @called, "webpacker:install expected to be called once, but was called #{@called} times."
+ end
end
- generator([destination_root], webpack: true).stub(:rails_command, command_check) do
+ generator([destination_root], webpack: "webpack").stub(:rails_command, command_check) do
quietly { generator.invoke_all }
end
assert_gem "webpacker"
end
+ def test_webpack_option_with_js_framework
+ command_check = -> command, *_ do
+ case command
+ when "webpacker:install"
+ @webpacker ||= 0
+ @webpacker += 1
+ assert_equal 1, @webpacker, "webpacker:install expected to be called once, but was called #{@webpacker} times."
+ when "webpacker:install:react"
+ @react ||= 0
+ @react += 1
+ assert_equal 1, @react, "webpacker:install:react expected to be called once, but was called #{@react} times."
+ end
+ end
+
+ generator([destination_root], webpack: "react").stub(:rails_command, command_check) do
+ quietly { generator.invoke_all }
+ end
+ end
+
def test_generator_if_skip_turbolinks_is_given
run_generator [destination_root, "--skip-turbolinks"]