Sha256: b1ec46801e407b3bc9cafdf2557471d87743d2c5a2cbfc300b2263ef66f71810

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

require "petitest/texts/base_text"

module Petitest
  module Texts
    class TestResultLineText < ::Petitest::Texts::BaseText
      # @return [Petitest::Test]
      attr_reader :test

      # @param test [Petitest::Test]
      def initialize(test:)
        @test = test
      end

      # @note Override
      def to_s
        indent(
          colorize("##{test.runner.test_method_name}", color_type),
          2 * (test.runner.test_group.nest_level + 1),
        )
      end

      private

      # @return [Symbol]
      def color_type
        case
        when test.runner.failed?
          :error
        when test.runner.skipped?
          :skip
        else
          :pass
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
petitest-0.3.1 lib/petitest/texts/test_result_line_text.rb
petitest-0.3.0 lib/petitest/texts/test_result_line_text.rb