Sha256: 6d9b96399a3cd5e52fe755c7e4642bf91399d471fc2152ae19065a39d784c62c

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

module StartingBlocks

  class ResultBuilder

    def build_from run_result
      load_the_output_from(run_result[:text])
        .merge(color: color,
               text: run_result[:text],
               exit_code: run_result[:exit_code],
               success:   run_result[:success])
    end

    private

    def color
      return :red unless tests_exist?
      return :red if problems_exist?
      return :yellow if skips_exist?
      :green
    end

    def load_the_output_from text
      @output = StartingBlocks::TextParser.new.parse text
    end

    def tests_exist?
      (@output[:tests] || 0) > 0
    end

    def problems_exist?
      ((@output[:errors] || 0) > 0) or ((@output[:failures] || 0) > 0)
    end

    def skips_exist?
      (@output[:skips] || 0) > 0
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
starting_blocks-1.3.1 lib/starting_blocks/result_builder.rb
starting_blocks-1.3.0 lib/starting_blocks/result_builder.rb