Commit eb41187d authored by Mark Lapierre's avatar Mark Lapierre

Report correct shared examples location

This fix makes the JSON formatter report the path the spec file that
includes the shared examples. The line number is the line in that
spec file that refers to the shared examples.
parent e8c7d7ed
...@@ -35,13 +35,15 @@ module QA ...@@ -35,13 +35,15 @@ module QA
private private
def format_example(example) def format_example(example)
file_path, line_number = location_including_shared_examples(example.metadata)
{ {
id: example.id, id: example.id,
description: example.description, description: example.description,
full_description: example.full_description, full_description: example.full_description,
status: example.execution_result.status.to_s, status: example.execution_result.status.to_s,
file_path: example.metadata[:file_path], file_path: file_path,
line_number: example.metadata[:line_number], line_number: line_number.to_i,
run_time: example.execution_result.run_time, run_time: example.execution_result.run_time,
pending_message: example.execution_result.pending_message, pending_message: example.execution_result.pending_message,
status_issue: example.metadata[:status_issue], status_issue: example.metadata[:status_issue],
...@@ -49,6 +51,15 @@ module QA ...@@ -49,6 +51,15 @@ module QA
screenshot: example.metadata[:screenshot] screenshot: example.metadata[:screenshot]
} }
end end
def location_including_shared_examples(metadata)
if metadata[:shared_group_inclusion_backtrace].empty?
[metadata[:file_path], metadata[:line_number]]
else
# If there are nested shared examples, the outermost location is last in the array
metadata[:shared_group_inclusion_backtrace].last.formatted_inclusion_location.split(':')
end
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment