@@ -42,8 +42,6 @@ class CodeLens
42
42
include Requests ::Support ::Common
43
43
include ActiveSupportTestCaseHelper
44
44
45
- BASE_COMMAND = "bin/rails test"
46
-
47
45
sig do
48
46
params (
49
47
response_builder : ResponseBuilders ::CollectionResponseBuilder [ Interface ::CodeLens ] ,
@@ -67,7 +65,7 @@ def on_call_node_enter(node)
67
65
return unless content
68
66
69
67
line_number = node . location . start_line
70
- command = "#{ BASE_COMMAND } #{ @path } :#{ line_number } "
68
+ command = "#{ test_command } #{ @path } :#{ line_number } "
71
69
add_test_code_lens ( node , name : content , command : command , kind : :example )
72
70
end
73
71
@@ -77,7 +75,7 @@ def on_def_node_enter(node)
77
75
method_name = node . name . to_s
78
76
if method_name . start_with? ( "test_" )
79
77
line_number = node . location . start_line
80
- command = "#{ BASE_COMMAND } #{ @path } :#{ line_number } "
78
+ command = "#{ test_command } #{ @path } :#{ line_number } "
81
79
add_test_code_lens ( node , name : method_name , command : command , kind : :example )
82
80
end
83
81
end
@@ -86,7 +84,7 @@ def on_def_node_enter(node)
86
84
def on_class_node_enter ( node )
87
85
class_name = node . constant_path . slice
88
86
if class_name . end_with? ( "Test" )
89
- command = "#{ BASE_COMMAND } #{ @path } "
87
+ command = "#{ test_command } #{ @path } "
90
88
add_test_code_lens ( node , name : class_name , command : command , kind : :group )
91
89
@group_id_stack . push ( @group_id )
92
90
@group_id += 1
@@ -103,6 +101,15 @@ def on_class_node_leave(node)
103
101
104
102
private
105
103
104
+ sig { returns ( String ) }
105
+ def test_command
106
+ if Gem . win_platform?
107
+ "ruby bin/rails test"
108
+ else
109
+ "bin/rails test"
110
+ end
111
+ end
112
+
106
113
sig { params ( node : Prism ::Node , name : String , command : String , kind : Symbol ) . void }
107
114
def add_test_code_lens ( node , name :, command :, kind :)
108
115
return unless @path
0 commit comments