Sha256: fa8f68ef13f63c0fcb20b57527d90276d2b54634efb0f3a4284f62f6c8cc9809

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

require 'blinky'

module StartingBlocks
  module Extensions
    class GreenOnSuccessRedOnFailure

      def initialize
        @light = Blinky.new.light
      end

      def receive_specs_to_run specs
        @spec_count = specs.count
        return if specs.count == 0
        change_color_to :yellow
      end

      def receive_results results
        return if @spec_count == 0
        if (results[:tests] || 0) == 0
          change_color_to :red
        elsif (results[:errors] || 0) > 0
          change_color_to :red
        elsif (results[:failures] || 0) > 0
          change_color_to :red
        elsif (results[:skips] || 0) > 0
          change_color_to :yellow
        else
          change_color_to :green
        end
      end

      def change_color_to(color)
        case color
        when :green
          @light.success!
        when :red
          @light.failure!
        when :yellow
          @light.building!
        end
      rescue
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
starting_blocks-0.0.17 lib/extensions/blinky.rb