Sha256: b1fecc0cee150ddd8f3f347a845e58a2afec732bea69fcc84e4426c121295595

Contents?: true

Size: 1.5 KB

Versions: 62

Compression:

Stored size: 1.5 KB

Contents

class Autotest::Result

  ##
  # Analyze test result lines and return the numbers in a hash.
  def initialize(autotest)
    @numbers = {}
    lines = autotest.results.map {|s| s.gsub(/(\e.*?m|\n)/, '') }   # remove escape sequences
    lines.reject! {|line| !line.match(/\d+\s+(example|test|scenario|step)s?/) }   # isolate result numbers
    lines.each do |line|
      prefix = nil
      line.scan(/([1-9]\d*)\s(\w+)/) do |number, kind|
        kind.sub!(/s$/, '')   # singularize
        kind.sub!(/failure/, 'failed')   # homogenize
        if prefix
          @numbers["#{prefix}-#{kind}"] = number.to_i
        else
          @numbers[kind] = number.to_i
          prefix = kind
        end
      end
    end
  end

  ##
  # Determine the testing framework used.
  def framework
    case
      when @numbers['test'] then 'test-unit'
      when @numbers['example'] then 'rspec'
      when @numbers['scenario'] then 'cucumber'
    end
  end

  ##
  # Determine whether a result exists at all.
  def exists?
    !@numbers.empty?
  end

  ##
  # Check whether a specific result is present.
  def has?(kind)
    @numbers.has_key?(kind)
  end

  ##
  # Get a plain result number.
  def [](kind)
    @numbers[kind]
  end

  ##
  # Get a labelled result number. The prefix is removed and the label pluralized if necessary.
  def get(kind)
    "#{@numbers[kind]} #{kind.sub(/^.*-/, '')}#{'s' if @numbers[kind] != 1 && !kind.match(/(ed|ing)$/)}" if @numbers[kind]
  end

  ##
  # Get the fatal error if any.
  def fatal_error
    
  end

end

Version data entries

62 entries across 62 versions & 5 rubygems

Version Path
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-2.0.0 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-1.142.3 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-1.120.3 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-1.61.3 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb
cloudsmith-api-1.42.3 vendor/bundle/ruby/2.6.0/gems/autotest-growl-0.2.16/lib/autotest/result.rb