4
4
require "test_helper"
5
5
6
6
class GotoRelevantFileTest < Minitest ::Test
7
- def setup
8
- Dir . stubs ( :pwd ) . returns ( "/workspace" )
9
- end
10
-
11
7
def test_when_input_is_test_file_returns_array_of_implementation_file_locations
12
8
stub_glob_pattern ( "**/goto_relevant_file.rb" , [ "lib/ruby_lsp/requests/goto_relevant_file.rb" ] )
13
9
14
10
test_file_path = "/workspace/test/requests/goto_relevant_file_test.rb"
15
11
expected = [ "/workspace/lib/ruby_lsp/requests/goto_relevant_file.rb" ]
16
12
17
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_file_path ) . perform
13
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_file_path , "/workspace" ) . perform
18
14
assert_equal ( expected , result )
19
15
end
20
16
@@ -26,7 +22,7 @@ def test_when_input_is_implementation_file_returns_array_of_test_file_locations
26
22
impl_path = "/workspace/lib/ruby_lsp/requests/goto_relevant_file.rb"
27
23
expected = [ "/workspace/test/requests/goto_relevant_file_test.rb" ]
28
24
29
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path ) . perform
25
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path , "/workspace" ) . perform
30
26
assert_equal ( expected , result )
31
27
end
32
28
@@ -44,7 +40,7 @@ def test_return_all_file_locations_that_have_the_same_highest_coefficient
44
40
"/workspace/test/integration/some_feature_test.rb" ,
45
41
]
46
42
47
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path ) . perform
43
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path , "/workspace" ) . perform
48
44
assert_equal ( expected . sort , result . sort )
49
45
end
50
46
@@ -53,7 +49,7 @@ def test_return_empty_array_when_no_filename_matches
53
49
stub_glob_pattern ( pattern , [ ] )
54
50
55
51
file_path = "/workspace/lib/ruby_lsp/requests/nonexistent_file.rb"
56
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( file_path ) . perform
52
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( file_path , "/workspace" ) . perform
57
53
assert_empty ( result )
58
54
end
59
55
@@ -63,7 +59,7 @@ def test_it_finds_implementation_when_file_has_test_suffix
63
59
test_path = "/workspace/test/feature_test.rb"
64
60
expected = [ "/workspace/lib/feature.rb" ]
65
61
66
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path ) . perform
62
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path , "/workspace" ) . perform
67
63
assert_equal ( expected , result )
68
64
end
69
65
@@ -73,7 +69,7 @@ def test_it_finds_implementation_when_file_has_spec_suffix
73
69
test_path = "/workspace/spec/feature_spec.rb"
74
70
expected = [ "/workspace/lib/feature.rb" ]
75
71
76
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path ) . perform
72
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path , "/workspace" ) . perform
77
73
assert_equal ( expected , result )
78
74
end
79
75
@@ -83,7 +79,7 @@ def test_it_finds_implementation_when_file_has_integration_test_suffix
83
79
test_path = "/workspace/test/feature_integration_test.rb"
84
80
expected = [ "/workspace/lib/feature.rb" ]
85
81
86
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path ) . perform
82
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path , "/workspace" ) . perform
87
83
assert_equal ( expected , result )
88
84
end
89
85
@@ -93,7 +89,7 @@ def test_it_finds_implementation_when_file_has_test_prefix
93
89
test_path = "/workspace/test/test_feature.rb"
94
90
expected = [ "/workspace/lib/feature.rb" ]
95
91
96
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path ) . perform
92
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path , "/workspace" ) . perform
97
93
assert_equal ( expected , result )
98
94
end
99
95
@@ -103,7 +99,7 @@ def test_it_finds_implementation_when_file_has_spec_prefix
103
99
test_path = "/workspace/test/spec_feature.rb"
104
100
expected = [ "/workspace/lib/feature.rb" ]
105
101
106
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path ) . perform
102
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path , "/workspace" ) . perform
107
103
assert_equal ( expected , result )
108
104
end
109
105
@@ -113,7 +109,7 @@ def test_it_finds_implementation_when_file_has_integration_test_prefix
113
109
test_path = "/workspace/test/integration_test_feature.rb"
114
110
expected = [ "/workspace/lib/feature.rb" ]
115
111
116
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path ) . perform
112
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( test_path , "/workspace" ) . perform
117
113
assert_equal ( expected , result )
118
114
end
119
115
@@ -124,7 +120,7 @@ def test_it_finds_tests_for_implementation
124
120
impl_path = "/workspace/lib/feature.rb"
125
121
expected = [ "/workspace/test/feature_test.rb" ]
126
122
127
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path ) . perform
123
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path , "/workspace" ) . perform
128
124
assert_equal ( expected , result )
129
125
end
130
126
@@ -135,7 +131,7 @@ def test_it_finds_specs_for_implementation
135
131
impl_path = "/workspace/lib/feature.rb"
136
132
expected = [ "/workspace/spec/feature_spec.rb" ]
137
133
138
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path ) . perform
134
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path , "/workspace" ) . perform
139
135
assert_equal ( expected , result )
140
136
end
141
137
@@ -146,7 +142,7 @@ def test_it_finds_integration_tests_for_implementation
146
142
impl_path = "/workspace/lib/feature.rb"
147
143
expected = [ "/workspace/test/feature_integration_test.rb" ]
148
144
149
- result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path ) . perform
145
+ result = RubyLsp ::Requests ::GotoRelevantFile . new ( impl_path , "/workspace" ) . perform
150
146
assert_equal ( expected , result )
151
147
end
152
148
0 commit comments