Class: Everqueen::Runner::TestRunner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner, test) ⇒ TestRunner

Returns a new instance of TestRunner.



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

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

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



25
26
27
# File 'lib/everqueen/runner.rb', line 25

def runner
  @runner
end

#testObject (readonly)

Returns the value of attribute test.



25
26
27
# File 'lib/everqueen/runner.rb', line 25

def test
  @test
end

Instance Method Details

#dotsObject



78
79
80
# File 'lib/everqueen/runner.rb', line 78

def dots
  examples; ""
end

#examplesObject



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

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

    previous_results = ""

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

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

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

#failed_examplesObject



70
71
72
# File 'lib/everqueen/runner.rb', line 70

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

#failure_messagesObject



82
83
84
85
86
# File 'lib/everqueen/runner.rb', line 82

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

#ioObject



36
37
38
# File 'lib/everqueen/runner.rb', line 36

def io
  runner.io
end

#passed?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/everqueen/runner.rb', line 74

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

#runObject



40
41
42
43
44
45
# File 'lib/everqueen/runner.rb', line 40

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

#sessionObject



32
33
34
# File 'lib/everqueen/runner.rb', line 32

def session
  runner.session
end