-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add custom formatter to solve nested issue (#75)
- Loading branch information
1 parent
a791001
commit 840745b
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "rspec/core/formatters/json_formatter" | ||
|
||
class NeotestFormatter < RSpec::Core::Formatters::JsonFormatter | ||
RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :seed, :close | ||
|
||
private | ||
|
||
def get_actual_inclusion_line_number(example) | ||
if example.metadata[:shared_group_inclusion_backtrace]&.any? | ||
example.metadata[:shared_group_inclusion_backtrace].first.inclusion_location[/(?<=:)\d+(?=:in)/] | ||
else | ||
example.metadata[:line_number] | ||
end | ||
end | ||
|
||
def format_example(example) | ||
result = super(example) | ||
result.merge( | ||
line_number: get_actual_inclusion_line_number(example) | ||
) | ||
end | ||
end |