Class: Evergreen::Runner::SpecRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/evergreen/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner, spec) ⇒ SpecRunner

Returns a new instance of SpecRunner.



29
30
31
32
# File 'lib/evergreen/runner.rb', line 29

def initialize(runner, spec)
  @runner = runner
  @spec = spec
end

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



27
28
29
# File 'lib/evergreen/runner.rb', line 27

def runner
  @runner
end

#specObject (readonly)

Returns the value of attribute spec.



27
28
29
# File 'lib/evergreen/runner.rb', line 27

def spec
  @spec
end

Instance Method Details

#dotsObject



80
81
82
# File 'lib/evergreen/runner.rb', line 80

def dots
  examples; ""
end

#examplesObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/evergreen/runner.rb', line 49

def examples
  @results ||= begin
    session.visit(spec.url)

    previous_results = ""

    session.wait_until(180) do
      dots = session.evaluate_script('Evergreen.dots')
      io.print dots.sub(/^#{Regexp.escape(previous_results)}/, '')
      io.flush
      previous_results = dots
      session.evaluate_script('Evergreen.done')
    end

    dots = session.evaluate_script('Evergreen.dots')
    io.print dots.sub(/^#{Regexp.escape(previous_results)}/, '')

    JSON.parse(session.evaluate_script('Evergreen.getResults()')).map do |row|
      Example.new(row)
    end
  end
end

#failed_examplesObject



72
73
74
# File 'lib/evergreen/runner.rb', line 72

def failed_examples
  examples.select { |example| not example.passed? }
end

#failure_messagesObject



84
85
86
87
88
# File 'lib/evergreen/runner.rb', line 84

def failure_messages
  unless passed?
    examples.map { |example| example.failure_message }.compact.join("\n\n")
  end
end

#ioObject



38
39
40
# File 'lib/evergreen/runner.rb', line 38

def io
  runner.io
end

#passed?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/evergreen/runner.rb', line 76

def passed?
  examples.all? { |example| example.passed? }
end

#runObject



42
43
44
45
46
47
# File 'lib/evergreen/runner.rb', line 42

def run
  io.puts dots
  io.puts failure_messages
  io.puts "\n#{examples.size} examples, #{failed_examples.size} failures"
  passed?
end

#sessionObject



34
35
36
# File 'lib/evergreen/runner.rb', line 34

def session
  runner.session
end