Class: Apophis::Runner
- Inherits:
-
Object
- Object
- Apophis::Runner
- Defined in:
- lib/apophis/runner.rb
Instance Method Summary collapse
-
#cleanup ⇒ Object
note: Appium::Driver.new(..).start_driver is sucky in that it populates $driver, which #promote_appium_methods rely on.
-
#initialize(log = nil) ⇒ Runner
constructor
A new instance of Runner.
- #start(caps) ⇒ Object
Constructor Details
#initialize(log = nil) ⇒ Runner
Returns a new instance of Runner.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/apophis/runner.rb', line 3 def initialize(log=nil) @log = log unless log @log = Logger.new($stdout) @log.formatter = proc do |severity, datetime, progname, msg| date_format = datetime.strftime("%Y-%m-%d %H:%M:%S") "[#{date_format}] #{severity}: #{msg}\n" end end end |
Instance Method Details
#cleanup ⇒ Object
note: Appium::Driver.new(..).start_driver is sucky in that it populates $driver, which #promote_appium_methods rely on. We’ll have no choice but chip-in on this nonsense when we want to do cleanups etc.
60 61 62 63 64 |
# File 'lib/apophis/runner.rb', line 60 def cleanup @log.info '---> cleaning up...' $driver.driver_quit if $driver @log.info '---> done.' end |
#start(caps) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/apophis/runner.rb', line 14 def start(caps) @log.info "\n#{Apophis::BANNER}\n" gm = GenymotionRunner.new gm.doctor! if caps[:runner] && caps[:runner][:genymotion] && gm.devices.empty? @log.info '---> no android device found, launching genymotion...' gm.launch(caps[:runner][:genymotion]) @log.info '---> devices available:' @log.info gm.devices.join("\n") end ar = AppiumRunner.new ar.doctor! appiums = ar.appiums @log.info "appiums: #{appiums}" if appiums.size > 0 @log.info '---> being a douch and killing all running appiums.' @log.info '---> improve me later to map caps->device->device uuid->appium->appium session.' appiums.each do |app| @log.info "---> killing appium #{ app }" ar.kill_and_wait(app[:port]) end end unless ar.any? @log.info '---> no appium found. launching...' launchinfo = ar.launch_and_wait caps[:appium_lib][:port] = launchinfo[:port] @log.info "---> done. wiring caps to appium #{launchinfo}" end @log.info "---> starting driver..." Appium::Driver.new(caps).start_driver Appium.promote_appium_methods Minitest::Spec @log.info "---> done" end |