Sha256: 52d2ff8a8453f089618a7dd2106ab29a85082f46620b83ff0570022ce70053fa

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

require "petitest/texts/base_text"

module Petitest
  module Texts
    class FailuresText < ::Petitest::Texts::BaseText
      # @return [Array<Petitest::Test>]
      attr_reader :tests

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

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

      private

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

      # @return [Array<Petitest::Textx::FailuresElementText>]
      def failures_element_texts
        tests.map.with_index do |test, index|
          ::Petitest::Texts::FailuresElementText.new(
            index: index,
            test: test,
          )
        end
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

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