class SleepingKingStudios::Tasks::Ci::RSpecEachResults

Encapsulates the results of an RSpecEach call.

Public Class Methods

new(results) click to toggle source

@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

==(other) click to toggle source

@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
duration() click to toggle source

@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
empty?() click to toggle source

@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
errored?() click to toggle source

@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
errored_count() click to toggle source

@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
errored_files() click to toggle source

@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
failing?() click to toggle source

@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
failing_files() click to toggle source

@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
failure_count() click to toggle source

@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
file_count() click to toggle source

@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
pending?() click to toggle source

@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
pending_count() click to toggle source

@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
pending_files() click to toggle source

@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
pluralize(count, singular, plural = nil) click to toggle source
# 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
to_h() click to toggle source

@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
to_s() click to toggle source

@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
tools() click to toggle source
# File lib/sleeping_king_studios/tasks/ci/rspec_each_results.rb, line 114
def tools
  SleepingKingStudios::Tools::Toolbelt.instance
end