class TurnipFormatter::Renderer::Html::StatisticsFeature

@resource [Array<TurnipFormatter::Resource::Scenario::XXX>]

Public Instance Methods

results() click to toggle source
# File lib/turnip_formatter/renderer/html/statistics_feature.rb, line 11
def results
  @results ||= features.map do |name, scenarios|
    analysis(name, scenarios)
  end
end

Private Instance Methods

analysis(name, scenarios) click to toggle source
# File lib/turnip_formatter/renderer/html/statistics_feature.rb, line 23
def analysis(name, scenarios)
  group = scenarios.group_by { |s| s.status }
  group.default = []

  info = OpenStruct.new(
    name: name,
    scenario_count: scenarios.size,
    passed_count: group[:passed].size,
    failed_count: group[:failed].size,
    pending_count: group[:pending].size,
    status: :failed
  )

  if info.failed_count.zero?
    info.status = info.pending_count.zero? ? :passed : :pending
  end

  info
end
features() click to toggle source
# File lib/turnip_formatter/renderer/html/statistics_feature.rb, line 19
def features
  @features ||= @resource.group_by { |s| s.feature.name }
end