Class: Superbot::Capybara::Runner
- Inherits:
-
Object
- Object
- Superbot::Capybara::Runner
- Defined in:
- lib/superbot/capybara/runner.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#finished ⇒ Object
Returns the value of attribute finished.
-
#region ⇒ Object
Returns the value of attribute region.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#script ⇒ Object
Returns the value of attribute script.
-
#test_result ⇒ Object
Returns the value of attribute test_result.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(browser: :local, region: nil) ⇒ Runner
constructor
A new instance of Runner.
- #kill_session ⇒ Object
- #run(script) ⇒ Object
- #wait_for_finish ⇒ Object
Constructor Details
#initialize(browser: :local, region: nil) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 |
# File 'lib/superbot/capybara/runner.rb', line 8 def initialize(browser: :local, region: nil) @browser = browser @region = region end |
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
44 45 46 |
# File 'lib/superbot/capybara/runner.rb', line 44 def browser @browser end |
#finished ⇒ Object
Returns the value of attribute finished.
44 45 46 |
# File 'lib/superbot/capybara/runner.rb', line 44 def finished @finished end |
#region ⇒ Object
Returns the value of attribute region.
44 45 46 |
# File 'lib/superbot/capybara/runner.rb', line 44 def region @region end |
#runner ⇒ Object
Returns the value of attribute runner.
44 45 46 |
# File 'lib/superbot/capybara/runner.rb', line 44 def runner @runner end |
#script ⇒ Object
Returns the value of attribute script.
44 45 46 |
# File 'lib/superbot/capybara/runner.rb', line 44 def script @script end |
#test_result ⇒ Object
Returns the value of attribute test_result.
44 45 46 |
# File 'lib/superbot/capybara/runner.rb', line 44 def test_result @test_result end |
Class Method Details
.run(script, browser: :local, region: nil) ⇒ Object
13 14 15 |
# File 'lib/superbot/capybara/runner.rb', line 13 def self.run(script, browser: :local, region: nil) new(browser: browser, region: region).run(script) end |
Instance Method Details
#kill_session ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/superbot/capybara/runner.rb', line 25 def kill_session runner&.kill rescue Timeout::Error p # do nothing ensure @runner = nil end |
#run(script) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/superbot/capybara/runner.rb', line 17 def run(script) puts "Attaching to #{browser} browser..." create_runner puts "Running test..." runner.in.writeln({ eval: script }.to_json) wait_for_finish end |
#wait_for_finish ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/superbot/capybara/runner.rb', line 33 def wait_for_finish loop do if finished @finished = false break end sleep 0.1 end end |