Sha256: c2d0a1ce35d5b45f2c65a4aaf7edb357fc1f442cd3abf6db0bc7054d26aebe70
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
require "petitest/texts/base_text" module Petitest module Texts class TestCountsText < ::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 [ text_of_count_of_test_cases, text_of_count_of_passed_test_cases, text_of_count_of_failed_test_cases, text_of_count_of_skipped_test_cases, ].join("\n") end # @return [Integer] def count_of_failed_test_cases test_cases.select(&:failed?).length end # @return [Integer] def count_of_passed_test_cases test_cases.select(&:passed?).length end # @return [Integer] def count_of_skipped_test_cases test_cases.select(&:skipped?).length end # @return [Integer] def count_of_test_cases test_cases.length end # @return [String] def heading "Counts:" end # @return [Integer] def max_digits_length @max_digits_length ||= count_of_test_cases.to_s.length end # @return [String] def text_of_count_of_failed_test_cases colorize("%#{max_digits_length}d failures" % count_of_failed_test_cases, :error) end # @return [String] def text_of_count_of_passed_test_cases colorize("%#{max_digits_length}d passes" % count_of_passed_test_cases, :pass) end # @return [String] def text_of_count_of_skipped_test_cases colorize("%#{max_digits_length}d skips" % count_of_skipped_test_cases, :skip) end # @return [String] def text_of_count_of_test_cases "%#{max_digits_length}d tests" % count_of_test_cases end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
petitest-0.2.1 | lib/petitest/texts/test_counts_text.rb |
petitest-0.2.0 | lib/petitest/texts/test_counts_text.rb |