Class: Evergreen::Runner::SpecRunner
- Inherits:
-
Object
- Object
- Evergreen::Runner::SpecRunner
- Defined in:
- lib/evergreen/runner.rb
Instance Attribute Summary collapse
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #dots ⇒ Object
- #examples ⇒ Object
- #failed_examples ⇒ Object
- #failure_messages ⇒ Object
-
#initialize(runner, spec) ⇒ SpecRunner
constructor
A new instance of SpecRunner.
- #io ⇒ Object
- #passed? ⇒ Boolean
- #run ⇒ Object
- #session ⇒ Object
Constructor Details
#initialize(runner, spec) ⇒ SpecRunner
Returns a new instance of SpecRunner.
26 27 28 29 |
# File 'lib/evergreen/runner.rb', line 26 def initialize(runner, spec) @runner = runner @spec = spec end |
Instance Attribute Details
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
24 25 26 |
# File 'lib/evergreen/runner.rb', line 24 def runner @runner end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
24 25 26 |
# File 'lib/evergreen/runner.rb', line 24 def spec @spec end |
Instance Method Details
#dots ⇒ Object
77 78 79 |
# File 'lib/evergreen/runner.rb', line 77 def dots examples; "" end |
#examples ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/evergreen/runner.rb', line 46 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_examples ⇒ Object
69 70 71 |
# File 'lib/evergreen/runner.rb', line 69 def failed_examples examples.select { |example| not example.passed? } end |
#failure_messages ⇒ Object
81 82 83 84 85 |
# File 'lib/evergreen/runner.rb', line 81 def unless passed? examples.map { |example| example. }.compact.join("\n\n") end end |
#io ⇒ Object
35 36 37 |
# File 'lib/evergreen/runner.rb', line 35 def io runner.io end |
#passed? ⇒ Boolean
73 74 75 |
# File 'lib/evergreen/runner.rb', line 73 def passed? examples.all? { |example| example.passed? } end |
#run ⇒ Object
39 40 41 42 43 44 |
# File 'lib/evergreen/runner.rb', line 39 def run io.puts dots io.puts io.puts "\n#{examples.size} examples, #{failed_examples.size} failures" passed? end |
#session ⇒ Object
31 32 33 |
# File 'lib/evergreen/runner.rb', line 31 def session runner.session end |