Sha256: 670982bb93b5249c55c94daee6ef33ec94e49cb6d941538a185818fc5b6d0815

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'colored'
##
# CucumberChecker checks the output for failed Scenarios
#
# @author dmasur
class CucumberChecker
  ##
  # Gives the Checkresult
  #
  # @return [Hash] Checkresult
  # @author dmasur
  def result
    @shell_output = begin
      `export COVERAGE=true; cucumber; export COVERAGE=;`
    rescue Errno::ENOENT
      "Cucumber not found"
    end
    { type: :cucumber, check_output: output, status: status }
  end

  private

    ##
    # Gives the Check Status
    #
    # @return [String] Checkstatus
    # @author dmasur
    def status
      if @shell_output.include? 'scenarios'
        regexp = /\d+ scenarios \((\d+) failed, \d+ passed\)/
        match_data = regexp.match(@shell_output)
        if match_data
          "#{match_data[1]} failed scenarios".red
        else
          "OK".green
        end
      else
        'N/A'
      end
    end

    ##
    # Cucumber Output
    #
    # @author dmasur
    def output
      case status
      when "N/A" then ''
      when 'OK'.green then ''
      else @shell_output
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rake_check-0.1.11 lib/rake_check/cucumber_checker.rb