From 89349a37d1316b210ad4b545283d0884eb618930 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:28:16 -0400 Subject: [PATCH] Use fixture for test --- test/setup_bundler_test.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/setup_bundler_test.rb b/test/setup_bundler_test.rb index dee4edfbec..85e75ed3bd 100644 --- a/test/setup_bundler_test.rb +++ b/test/setup_bundler_test.rb @@ -484,20 +484,14 @@ def test_ensures_lockfile_remotes_are_relative_to_default_gemfile def test_ruby_lsp_rails_is_automatically_included_in_rails_apps Dir.mktmpdir do |dir| + FileUtils.mkdir("#{dir}/config") + FileUtils.cp("test/fixtures/rails_application.rb", "#{dir}/config/application.rb") Dir.chdir(dir) do File.write(File.join(dir, "Gemfile"), <<~GEMFILE) source "https://rubygems.org" gem "rails" GEMFILE - FileUtils.mkdir(File.join(dir, "config")) - File.write(File.join(dir, "config", "application.rb"), <<~RUBY) - module MyApp - class Application < Rails::Application - end - end - RUBY - capture_subprocess_io do Bundler.with_unbundled_env do # Run bundle install to generate the lockfile @@ -516,6 +510,8 @@ class Application < Rails::Application assert_path_exists(".ruby-lsp/Gemfile") assert_match('gem "ruby-lsp-rails"', File.read(".ruby-lsp/Gemfile")) end + ensure + FileUtils.rm_rf("#{dir}/config") if Dir.exist?("#{dir}/config") end end