Sha256: b4594cb2f4bdd92bbee5130b5b4a4099a792fa1db8ae710b8ea454be22571acb

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

require "petitest/texts/base_text"

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

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

      # @note Override
      def to_s
        elements = []
        elements << test.runner.error_class_name unless test.runner.error.is_a?(::Petitest::AssertionFailureError)
        elements << test.runner.error_message unless test.runner.error_message.empty?
        string = elements.join("\n")
        colorize(string, :error)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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