lib/petitest/texts/test_counts_text.rb in petitest-0.2.1 vs lib/petitest/texts/test_counts_text.rb in petitest-0.3.0
- old
+ new
@@ -1,16 +1,16 @@
require "petitest/texts/base_text"
module Petitest
module Texts
class TestCountsText < ::Petitest::Texts::BaseText
- # @return [Array<Petitest::TestCase>]
- attr_reader :test_cases
+ # @return [Array<Petitest::Test>]
+ attr_reader :tests
- # @param test_cases [Array<Petitest::TestCase>]
- def initialize(test_cases:)
- @test_cases = test_cases
+ # @param tests [Array<Petitest::Test>]
+ def initialize(tests:)
+ @tests = tests
end
# @note Override
def to_s
[
@@ -22,64 +22,64 @@
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,
+ text_of_count_of_tests,
+ text_of_count_of_passed_tests,
+ text_of_count_of_failed_tests,
+ text_of_count_of_skipped_tests,
].join("\n")
end
# @return [Integer]
- def count_of_failed_test_cases
- test_cases.select(&:failed?).length
+ def count_of_failed_tests
+ tests.map(&:runner).select(&:failed?).length
end
# @return [Integer]
- def count_of_passed_test_cases
- test_cases.select(&:passed?).length
+ def count_of_passed_tests
+ tests.map(&:runner).select(&:passed?).length
end
# @return [Integer]
- def count_of_skipped_test_cases
- test_cases.select(&:skipped?).length
+ def count_of_skipped_tests
+ tests.map(&:runner).select(&:skipped?).length
end
# @return [Integer]
- def count_of_test_cases
- test_cases.length
+ def count_of_tests
+ tests.length
end
# @return [String]
def heading
"Counts:"
end
# @return [Integer]
def max_digits_length
- @max_digits_length ||= count_of_test_cases.to_s.length
+ @max_digits_length ||= count_of_tests.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)
+ def text_of_count_of_failed_tests
+ colorize("%#{max_digits_length}d failures" % count_of_failed_tests, :error)
end
# @return [String]
- def text_of_count_of_passed_test_cases
- colorize("%#{max_digits_length}d passes" % count_of_passed_test_cases, :pass)
+ def text_of_count_of_passed_tests
+ colorize("%#{max_digits_length}d passes" % count_of_passed_tests, :pass)
end
# @return [String]
- def text_of_count_of_skipped_test_cases
- colorize("%#{max_digits_length}d skips" % count_of_skipped_test_cases, :skip)
+ def text_of_count_of_skipped_tests
+ colorize("%#{max_digits_length}d skips" % count_of_skipped_tests, :skip)
end
# @return [String]
- def text_of_count_of_test_cases
- "%#{max_digits_length}d tests" % count_of_test_cases
+ def text_of_count_of_tests
+ "%#{max_digits_length}d tests" % count_of_tests
end
end
end
end