Sha256: a5307b768425b1057f188ed20639d03bbe6d7f35fa50669bbd8f899cbc09d728

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 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
      if Dir["features"].empty?
        return { type: :cucumber, check_output: '', status: "Not found".green }
      else
        `export COVERAGE=true; cucumber features; export COVERAGE=;`
      end
    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? 'scenario'
      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

5 entries across 5 versions & 1 rubygems

Version Path
rake_check-0.3.5 lib/rake_check/cucumber_checker.rb
rake_check-0.3.4 lib/rake_check/cucumber_checker.rb
rake_check-0.3.3 lib/rake_check/cucumber_checker.rb
rake_check-0.3.2 lib/rake_check/cucumber_checker.rb
rake_check-0.3.1 lib/rake_check/cucumber_checker.rb