From ee8d7850fd38b4602dc1d40323addc3448b60947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 23 Jun 2018 13:27:19 -0300 Subject: Generate bundler-compatible bundler binstub --- railties/lib/rails/generators/app_base.rb | 6 ++++++ railties/lib/rails/generators/rails/app/app_generator.rb | 2 ++ railties/lib/rails/generators/rails/app/templates/bin/bundle.tt | 2 -- railties/test/generators/api_app_generator_test.rb | 1 - railties/test/generators/app_generator_test.rb | 9 ++++++--- 5 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 railties/lib/rails/generators/rails/app/templates/bin/bundle.tt (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index f51542f3ec..3c5dfb2e92 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -458,6 +458,12 @@ module Rails end end + def generate_bundler_binstub + if bundle_install? + bundle_command("binstubs bundler") + end + end + def generate_spring_binstubs if bundle_install? && spring_install? bundle_command("exec spring binstub --all") diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 34067240d7..cc45a64b25 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -299,6 +299,8 @@ module Rails build(:bin) end + public_task :generate_bundler_binstub + def update_bin_files build(:bin_when_updating) end diff --git a/railties/lib/rails/generators/rails/app/templates/bin/bundle.tt b/railties/lib/rails/generators/rails/app/templates/bin/bundle.tt deleted file mode 100644 index a84f0afe47..0000000000 --- a/railties/lib/rails/generators/rails/app/templates/bin/bundle.tt +++ /dev/null @@ -1,2 +0,0 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -load Gem.bin_path('bundler', 'bundle') diff --git a/railties/test/generators/api_app_generator_test.rb b/railties/test/generators/api_app_generator_test.rb index 9c523ad372..c2540f4091 100644 --- a/railties/test/generators/api_app_generator_test.rb +++ b/railties/test/generators/api_app_generator_test.rb @@ -118,7 +118,6 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase app/views/layouts app/views/layouts/mailer.html.erb app/views/layouts/mailer.text.erb - bin/bundle bin/rails bin/rake bin/setup diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 58a6067cee..4f6ff222ef 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -37,7 +37,6 @@ DEFAULT_APP_FILES = %w( app/views/layouts/application.html.erb app/views/layouts/mailer.html.erb app/views/layouts/mailer.text.erb - bin/bundle bin/rails bin/rake bin/setup @@ -764,6 +763,10 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_gem "spring" end + def test_bundler_binstub + assert_bundler_command_called("binstubs bundler") + end + def test_spring_binstubs jruby_skip "spring doesn't run on JRuby" @@ -945,7 +948,7 @@ class AppGeneratorTest < Rails::Generators::TestCase template end - sequence = ["git init", "install", "exec spring binstub --all", "echo ran after_bundle"] + sequence = ["git init", "binstubs bundler", "install", "exec spring binstub --all", "echo ran after_bundle"] @sequence_step ||= 0 ensure_bundler_first = -> command, options = nil do assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}" @@ -962,7 +965,7 @@ class AppGeneratorTest < Rails::Generators::TestCase end end - assert_equal 4, @sequence_step + assert_equal 5, @sequence_step end def test_gitignore -- cgit v1.2.3