Sha256: c71ecd58ad3bd810c4a30fb3b69395f9ecaaaad691a69e2a5ea81929cf7225dd

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

require "petitest/texts/base_text"

module Petitest
  module Texts
    class TestCaseResultLineText < ::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
        indent(
          colorize("##{test_case.test_method.method_name}", color_type),
          2 * (test_case.test_group_class.nest_level + 1),
        )
      end

      private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
petitest-0.2.1 lib/petitest/texts/test_case_result_line_text.rb