Sha256: 0180cbd9cc6e2cce348623080f77f8b9bc94f8a29f6e78289630f159084a41e9

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

require "petitest/texts/base_text"

module Petitest
  module Texts
    class ErrorsText < ::Petitest::Texts::BaseText
      # @return [Array<Petitest::TestCase>]
      attr_reader :test_cases

      # @param test_cases [Array<Petitest::TestCase>]
      def initialize(test_cases:)
        @test_cases = test_cases
      end

      # @note Override
      def to_s
        [
          heading,
          indent(body, 2),
        ].join("\n\n")
      end

      private

      # @return [String]
      def body
        errors_element_texts.join("\n\n")
      end

      # @return [Array<Petitest::Textx::FailuresElementText>]
      def errors_element_texts
        test_cases.map.with_index do |test_case, index|
          ::Petitest::Texts::ErrorsElementText.new(
            index: index,
            test_case: test_case,
          )
        end
      end

      # @return [String]
      def heading
        "Errors:"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
petitest-0.1.3 lib/petitest/texts/errors_text.rb
petitest-0.1.2 lib/petitest/texts/errors_text.rb
petitest-0.1.1 lib/petitest/texts/errors_text.rb
petitest-0.1.0 lib/petitest/texts/errors_text.rb