Sha256: c315464b0ca4ea72804956676937af84e70f4930fad54fe6590bfa20a95a13a6
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
require "petitest/texts/base_text" module Petitest module Texts class RaisedCodeText < ::Petitest::Texts::BaseText # @return [Petitest::TestCase] attr_reader :test_case # @param test_case [Petitest::TestCase] def initialize(test_case:) @test_case = test_case end # @note Override def to_s if content = caller_file_content content.lines[caller_line_number - 1].strip else "" end end private # @return [String, nil] def caller_file_content if caller_path && ::FileTest.file?(caller_path) ::File.read(caller_path) end end # @return [String, nil] def caller_line_number if caller_segments[1] caller_segments[1].to_i end end # @return [String, nil] def caller_path caller_segments[0] end # @return [Array<String>] def caller_segments @caller_segments ||= begin if test_case.filtered_backtrace[0] test_case.filtered_backtrace[0].split(":", 3) else [] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
petitest-0.2.1 | lib/petitest/texts/raised_code_text.rb |
petitest-0.2.0 | lib/petitest/texts/raised_code_text.rb |