Class: Evergreen::Runner

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

Defined Under Namespace

Classes: Example, SpecRunner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = STDOUT) ⇒ Runner

Returns a new instance of Runner


90
91
92
# File 'lib/evergreen/runner.rb', line 90

def initialize(io=STDOUT)
  @io = io
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io


88
89
90
# File 'lib/evergreen/runner.rb', line 88

def io
  @io
end

#suiteObject (readonly)

Returns the value of attribute suite


88
89
90
# File 'lib/evergreen/runner.rb', line 88

def suite
  @suite
end

Instance Method Details

#dotsObject


127
128
129
# File 'lib/evergreen/runner.rb', line 127

def dots
  spec_runners.map { |spec_runner| spec_runner.dots }.join
end

#examplesObject


115
116
117
# File 'lib/evergreen/runner.rb', line 115

def examples
  spec_runners.map { |spec_runner| spec_runner.examples }.flatten
end

#failed_examplesObject


119
120
121
# File 'lib/evergreen/runner.rb', line 119

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

#failure_messagesObject


131
132
133
134
135
# File 'lib/evergreen/runner.rb', line 131

def failure_messages
  unless passed?
    spec_runners.map { |spec_runner| spec_runner.failure_messages }.compact.join("\n\n")
  end
end

#passed?Boolean

Returns:

  • (Boolean)

123
124
125
# File 'lib/evergreen/runner.rb', line 123

def passed?
  spec_runners.all? { |spec_runner| spec_runner.passed? }
end

#runObject


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/evergreen/runner.rb', line 98

def run
  before = Time.now

  io.puts ""
  io.puts dots.to_s
  io.puts ""
  if failure_messages
    io.puts failure_messages
    io.puts ""
  end

  seconds = "%.2f" % (Time.now - before)
  io.puts "Finished in #{seconds} seconds"
  io.puts "#{examples.size} examples, #{failed_examples.size} failures"
  passed?
end

#sessionObject


137
138
139
# File 'lib/evergreen/runner.rb', line 137

def session
  @session ||= Capybara::Session.new(Evergreen.driver, Evergreen.application)
end

#spec_runner(spec) ⇒ Object


94
95
96
# File 'lib/evergreen/runner.rb', line 94

def spec_runner(spec)
  SpecRunner.new(self, spec)
end