From 582b3ca8cb7cccca4493310688f553a9e2bf565d Mon Sep 17 00:00:00 2001 From: Josh LeBlanc Date: Tue, 1 Nov 2022 09:48:55 -0300 Subject: [PATCH] Support ok on windows Absolute paths in windows include the drive letter, (`C:\foo\bar`), which adds another colon in the path. Caller always returns the calls in the format of `path:line number:`, so we can safely match those directly with regex and return them, regardless of platform. --- lib/magic_test/support.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/magic_test/support.rb b/lib/magic_test/support.rb index 9b1e3eb..d81498e 100644 --- a/lib/magic_test/support.rb +++ b/lib/magic_test/support.rb @@ -121,7 +121,7 @@ def get_last def get_last_caller(caller) caller.select { |s| s.include?("/test/") || s.include?("/spec/") } .reject { |s| s.include?("helper") } - .first.split(":").first(2) + .first.match(/^(.+):(\d+):.*$/).to_a.last(2) end end end