Sha256: 70d506ab1db65e5f2b89d0e6e8ec7f680acd5a0f77e44a2591d39eebe6006e92

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 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'
        match_data = /\d+ scenarios \((\d+) failed, \d+ passed\)/.match(@shell_output)
        if match_data
          failed_scenarios = match_data[1]
          "#{failed_scenarios} failed scenarios".red
        else
          "OK".green
        end
      else
        'N/A'
      end
    end

    ##
    # Cucumber Output
    #
    # @author dmasur
    def output
      if status == "N/A"
        ''
      elsif status == "OK".green
        ''
      else
        @shell_output
      end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rake_check-0.1.8 lib/rake_check/cucumber_checker.rb
rake_check-0.1.7 lib/rake_check/cucumber_checker.rb