6
6
7
7
class SetupBundlerTest < Minitest ::Test
8
8
def test_does_nothing_when_running_in_the_ruby_lsp
9
- Object . any_instance . expects ( :system ) . with ( bundle_install_command ( update : false ) )
9
+ Object . any_instance . expects ( :system ) . with ( bundle_install_command )
10
10
run_script ( "/some/path/ruby-lsp" )
11
11
refute_path_exists ( ".ruby-lsp" )
12
12
end
13
13
14
14
def test_does_nothing_if_both_ruby_lsp_and_debug_are_in_the_bundle
15
- Object . any_instance . expects ( :system ) . with ( bundle_install_command ( update : false ) )
15
+ Object . any_instance . expects ( :system ) . with ( bundle_install_command )
16
16
Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { "ruby-lsp" => true , "debug" => true } )
17
17
run_script
18
18
refute_path_exists ( ".ruby-lsp" )
19
19
end
20
20
21
+ def test_removes_ruby_lsp_folder_if_both_gems_were_added_to_the_bundle
22
+ Object . any_instance . expects ( :system ) . with ( bundle_install_command )
23
+ Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { "ruby-lsp" => true , "debug" => true } )
24
+ FileUtils . mkdir ( ".ruby-lsp" )
25
+ run_script
26
+ refute_path_exists ( ".ruby-lsp" )
27
+ ensure
28
+ FileUtils . rm_r ( ".ruby-lsp" ) if Dir . exist? ( ".ruby-lsp" )
29
+ end
30
+
21
31
def test_creates_custom_bundle
22
32
Object . any_instance . expects ( :system ) . with ( bundle_install_command ( ".ruby-lsp/Gemfile" ) )
23
33
Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { } )
@@ -34,7 +44,7 @@ def test_creates_custom_bundle
34
44
35
45
def test_copies_gemfile_lock_when_modified
36
46
Object . any_instance . expects ( :system ) . with ( bundle_install_command ( ".ruby-lsp/Gemfile" ) )
37
- Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { } )
47
+ Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { } ) . twice
38
48
FileUtils . mkdir ( ".ruby-lsp" )
39
49
FileUtils . touch ( ".ruby-lsp/Gemfile.lock" )
40
50
# Wait a little bit so that the modified timestamps don't match
@@ -50,7 +60,7 @@ def test_copies_gemfile_lock_when_modified
50
60
51
61
def test_does_not_copy_gemfile_lock_when_not_modified
52
62
Object . any_instance . expects ( :system ) . with ( bundle_install_command ( ".ruby-lsp/Gemfile" ) )
53
- Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { } )
63
+ Bundler ::LockfileParser . any_instance . expects ( :dependencies ) . returns ( { } ) . twice
54
64
FileUtils . mkdir ( ".ruby-lsp" )
55
65
FileUtils . cp ( "Gemfile.lock" , ".ruby-lsp/Gemfile.lock" )
56
66
@@ -78,17 +88,13 @@ def run_script(path = "/fake/project/path")
78
88
RubyLsp ::SetupBundler . new ( path ) . setup!
79
89
end
80
90
81
- def bundle_install_command ( bundle_gemfile = nil , update : true )
91
+ def bundle_install_command ( bundle_gemfile = nil )
82
92
path = Bundler . settings [ "path" ]
83
93
84
94
command = +""
85
95
command << "BUNDLE_PATH=#{ File . expand_path ( path , Dir . pwd ) } " if path
86
96
command << "BUNDLE_GEMFILE=#{ bundle_gemfile } " if bundle_gemfile
87
- command << if update
88
- "bundle update ruby-lsp debug "
89
- else
90
- "bundle install "
91
- end
97
+ command << "bundle install "
92
98
command << "1>&2"
93
99
end
94
100
end
0 commit comments