lib/petitest/texts/raised_code_text.rb in petitest-0.1.3 vs lib/petitest/texts/raised_code_text.rb in petitest-0.2.0

- old
+ new

@@ -22,27 +22,35 @@ private # @return [String, nil] def caller_file_content - if ::FileTest.file?(caller_path) + if caller_path && ::FileTest.file?(caller_path) ::File.read(caller_path) end end - # @return [String] + # @return [String, nil] def caller_line_number - caller_segments[1].to_i + if caller_segments[1] + caller_segments[1].to_i + end end - # @return [String] + # @return [String, nil] def caller_path caller_segments[0] end # @return [Array<String>] def caller_segments - @caller_segments ||= test_case.filtered_backtrace[0].split(":", 3) + @caller_segments ||= begin + if test_case.filtered_backtrace[0] + test_case.filtered_backtrace[0].split(":", 3) + else + [] + end + end end end end end