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(suite, io = STDOUT) ⇒ Runner

Returns a new instance of Runner.



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

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

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



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

def io
  @io
end

#suiteObject (readonly)

Returns the value of attribute suite.



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

def suite
  @suite
end

Instance Method Details

#dotsObject



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

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

#examplesObject



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

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

#failed_examplesObject



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

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

#failure_messagesObject



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

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

#passed?Boolean

Returns:

  • (Boolean)


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

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

#runObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/evergreen/runner.rb', line 102

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



141
142
143
# File 'lib/evergreen/runner.rb', line 141

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

#spec_runner(spec) ⇒ Object



98
99
100
# File 'lib/evergreen/runner.rb', line 98

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