Skip to content

Commit

Permalink
Seperate test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Aug 20, 2024
1 parent 39c3be0 commit 09b6840
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/setup_bundler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,37 @@ def test_ensures_lockfile_remotes_are_relative_to_default_gemfile
end

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

capture_subprocess_io do
Bundler.with_unbundled_env do
# Run bundle install to generate the lockfile
system("bundle install")
end
end

Object.any_instance.expects(:system).with(
bundle_env(".ruby-lsp/Gemfile"),
"(bundle check || bundle install) 1>&2",
).returns(true)
Bundler.with_unbundled_env do
run_script
end

assert_path_exists(".ruby-lsp/Gemfile")
assert_match('gem "ruby-lsp-rails"', File.read(".ruby-lsp/Gemfile"))
end
end
end

def test_ruby_lsp_rails_detection_handles_lang_from_environment
original_encoding = Encoding.default_external
Encoding.default_external = "us-ascii"

Expand Down

0 comments on commit 09b6840

Please sign in to comment.