Sha256: 719ac8de7d5b092ab17d06ac9243c02cc245a8174ff97d6abb3b3c3bf6604f61

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Evergreen
  class Runner
    attr_reader :spec

    def self.run(root)
      runners = Spec.all(root).map { |spec| new(spec) }
      runners.each do |runner|
        if runner.passed?
          print '.'
        else
          print 'F'
        end
      end
      puts ""

      runners.each do |runner|
        puts runner.failure_message unless runner.passed?
      end
    end

    def initialize(spec)
      @spec = spec
    end

    def passed?
      failed_examples.empty?
    end

    def failed_examples
      results.select { |row| !row.passed }
    end

    def failure_message
      failed_examples.map do |row|
        <<-ERROR
  Failed: #{row.name}
      #{row.message}
      in #{row.trace.fileName}:#{row.trace.lineNumber}
        ERROR
      end.join("\n\n")
    end

    def results
      @results ||= begin
        session = Capybara::Session.new(:envjs, Evergreen.application(spec.root))
        session.visit(spec.url)
        session.evaluate_script('jasmine.results')
      end
    end

  end
end




Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evergreen-0.1 lib/evergreen/runner.rb