aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2018-06-23 13:52:11 -0300
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2018-06-23 13:52:11 -0300
commitd2a91a7f90584dd3552430740c549d8c9257a588 (patch)
tree71ab2702f19c00e3fb4f7c324be727ca0ac105c3
parent96d2c228e31e5fe9b3159c5c52051c589d3c384f (diff)
downloadrails-d2a91a7f90584dd3552430740c549d8c9257a588.tar.gz
rails-d2a91a7f90584dd3552430740c549d8c9257a588.tar.bz2
rails-d2a91a7f90584dd3552430740c549d8c9257a588.zip
Factor out some common bundler mocking logic
-rw-r--r--railties/test/generators/app_generator_test.rb29
1 files changed, 9 insertions, 20 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index d8e9ae3369..00ca8cad0d 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -760,21 +760,8 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_spring_binstubs
jruby_skip "spring doesn't run on JRuby"
- command_check = -> command do
- @binstub_called ||= 0
- case command
- when "install"
- # Called when running bundle, we just want to stub it so nothing to do here.
- when "exec spring binstub --all"
- @binstub_called += 1
- assert_equal 1, @binstub_called, "exec spring binstub --all expected to be called once, but was called #{@install_called} times."
- end
- end
-
- generator.stub :bundle_command, command_check do
- quietly { generator.invoke_all }
- end
+ assert_bundler_command_called("exec spring binstub --all")
end
def test_spring_no_fork
@@ -1042,15 +1029,17 @@ class AppGeneratorTest < Rails::Generators::TestCase
def assert_generates_with_bundler(options = {})
generator([destination_root], options)
+ assert_bundler_command_called("install")
+ end
+
+ def assert_bundler_command_called(target_command)
command_check = -> command do
- @install_called ||= 0
+ @command_called ||= 0
case command
- when "install"
- @install_called += 1
- assert_equal 1, @install_called, "install expected to be called once, but was called #{@install_called} times"
- when "exec spring binstub --all"
- # Called when running tests with spring, let through unscathed.
+ when target_command
+ @command_called += 1
+ assert_equal 1, @command_called, "#{command} expected to be called once, but was called #{@command_called} times."
end
end