Class: Konacha::SpecRunner
- Inherits:
-
Object
- Object
- Konacha::SpecRunner
- Defined in:
- lib/konacha/runner.rb
Instance Attribute Summary collapse
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
-
#initialize(runner, spec) ⇒ SpecRunner
constructor
A new instance of SpecRunner.
- #io ⇒ Object
- #run ⇒ Object
- #session ⇒ Object
Constructor Details
#initialize(runner, spec) ⇒ SpecRunner
Returns a new instance of SpecRunner.
57 58 59 60 |
# File 'lib/konacha/runner.rb', line 57 def initialize(runner, spec) @runner = runner @spec = spec end |
Instance Attribute Details
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
55 56 57 |
# File 'lib/konacha/runner.rb', line 55 def examples @examples end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
55 56 57 |
# File 'lib/konacha/runner.rb', line 55 def runner @runner end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
55 56 57 |
# File 'lib/konacha/runner.rb', line 55 def spec @spec end |
Instance Method Details
#io ⇒ Object
66 67 68 |
# File 'lib/konacha/runner.rb', line 66 def io runner.io end |
#run ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/konacha/runner.rb', line 70 def run session.visit(spec.url) dots_printed = 0 begin sleep 0.1 done, dots = session.evaluate_script('[Konacha.done, Konacha.dots]') if dots io.write dots[dots_printed..-1] io.flush dots_printed = dots.length end end until done @examples = JSON.parse(session.evaluate_script('Konacha.getResults()')).map do |row| Example.new(row) end rescue => e raise Konacha::Error, "Error communicating with browser process: #{e.inspect}" end |
#session ⇒ Object
62 63 64 |
# File 'lib/konacha/runner.rb', line 62 def session runner.session end |