Class: Everqueen::Runner

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

Defined Under Namespace

Classes: Example, TestRunner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = STDOUT) ⇒ Runner

Returns a new instance of Runner.



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

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

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



89
90
91
# File 'lib/everqueen/runner.rb', line 89

def io
  @io
end

#suiteObject (readonly)

Returns the value of attribute suite.



89
90
91
# File 'lib/everqueen/runner.rb', line 89

def suite
  @suite
end

Instance Method Details

#dotsObject



128
129
130
# File 'lib/everqueen/runner.rb', line 128

def dots
  test_runners.map { |test_runner| test_runner.dots }.join
end

#examplesObject



116
117
118
# File 'lib/everqueen/runner.rb', line 116

def examples
  test_runners.map { |test_runner| test_runner.examples }.flatten
end

#failed_examplesObject



120
121
122
# File 'lib/everqueen/runner.rb', line 120

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

#failure_messagesObject



132
133
134
135
136
# File 'lib/everqueen/runner.rb', line 132

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

#passed?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/everqueen/runner.rb', line 124

def passed?
  test_runners.all? { |test_runner| test_runner.passed? }
end

#runObject



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

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} assertions, #{failed_examples.size} failures"
  passed?
end

#sessionObject



138
139
140
# File 'lib/everqueen/runner.rb', line 138

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

#test_runner(test) ⇒ Object



95
96
97
# File 'lib/everqueen/runner.rb', line 95

def test_runner(test)
  TestRunner.new(self, test)
end