class SleepingKingStudios::Tasks::Ci::RSpecEachResults
Encapsulates the results of an RSpecEach call.
Public Class Methods
@param results [Hash] The raw results of the RSpecEach call.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 9 def initialize results @results = results end
Public Instance Methods
@param other [RSpecEachResults] The other results object to compare.
@return [Boolean] True if the results are equal, otherwise false.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 16 def == other if other.is_a?(Hash) empty? ? other.empty? : to_h == other elsif other.is_a?(RSpecEachResults) to_h == other.to_h else false end # if-elsif-else end
@return [Float] The duration value.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 27 def duration @results.fetch('duration', 0.0) end
@return [Boolean] True if there are no files, otherwise false.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 32 def empty? file_count.zero? end
@return [Boolean] True if there are any errored files, otherwise false.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 37 def errored? !errored_count.zero? end
@return [Integer] The number of errored files.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 42 def errored_count errored_files.count end
@return [Array] The list of errored file names.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 47 def errored_files @results.fetch('errored_files', []) end
@return [Boolean] True if there are any failing files, otherwise false.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 52 def failing? !failure_count.zero? end
@return [Array] The list of failing file names.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 57 def failing_files @results.fetch('failing_files', []) end
@return [Integer] The number of failing files.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 62 def failure_count failing_files.count end
@return [Integer] The total file count.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 67 def file_count @results.fetch('file_count', 0) end
@return [Boolean] True if there are any pending files, otherwise false.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 72 def pending? !pending_count.zero? end
@return [Integer] The number of pending files.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 77 def pending_count pending_files.count end
@return [Array] The list of pending file names.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 82 def pending_files @results.fetch('pending_files', []) end
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 86 def pluralize count, singular, plural = nil "#{count} #{tools.int.pluralize count, singular, plural}" end
@return [Hash] The hash representation of the results.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 91 def to_h { 'failing_files' => failing_files, 'pending_files' => pending_files, 'errored_files' => errored_files, 'file_count' => file_count, 'duration' => duration } # end hash end
@return [String] The string representation of the results.
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 102 def to_s str = "#{file_count} files" str << ', ' << pluralize(failure_count, 'failure') str << ", #{pending_count} pending" if pending? str << ", #{errored_count} errored" if errored? str << " in #{duration.round(2)} seconds" end
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 114 def tools SleepingKingStudios::Tools::Toolbelt.instance end