Closed merof-code closed 2 weeks ago
I went ahead, and searched for a solution. Since I don't use rspec, I will only look to the minitest code. I figured we could start by changing the way the path to file is searched
just by changing it so here
_, line = runnable.instance_method(test_name).source_location
# we get path from the runnable definition, this prevents problems
# like method defined by shoulda (returns gem path)
path, = Object.const_source_location(runnable.to_s)
this, as far as I know, should not interfere with anything, and allows the tests to show up in the UI
I will look around and make a pull request with at least this change only
What happened to the #90? It has a few issues, but can't it just merge anyway?
This can be labeled as "support for Unbound methods"
adding this bit of code to the Tests#build_list
unbound_flag = runnable.instance_method(test_name).is_a?(UnboundMethod)
line = -1 if unbound_flag
...
file_tests.sort_by! { |t| t[:line_number] }
max_line = file_tests[-1]&.[](:line_number) || 0
max_line = 0 if max_line.negative?
file_tests.each do |t|
t[:line_number] = max_line + t[:index] + 1 if t[:line_number].negative?
t[:id] = "#{t[:file_path]}[#{t[:line_number]}]"
end
And do the running based on method name rather then its position And that would be it, if we exclude the fact that all the methods will point to a 'random' line in a file
Versions
explorer v0.9.2 Ruby 3.1.4 Rails 7.2 Minitest with rails
Problem
I see that when I added should gem and added a matcher, for example
The json that gets passed around from the
vscode:minitest:list
does contain the methods, but they are listed asWhich makes them appear in a new category names![image](https://github.com/connorshea/vscode-ruby-test-adapter/assets/62021407/04a63f65-feca-4231-acae-9d8aabb7b3e7)
.
in the menu.This is like a feature request.