default_platform :ios

after_all do |lane|
  stop_sinatra if lane == :test_push_notification
end

lane :start_sinatra do
  sh('nohup bundle exec ruby sinatra.rb > sinatra_log.txt 2>&1 &')
end

lane :stop_sinatra do
  sh('lsof -t -i:4567 | xargs kill -9')
end

lane :test_push_notification do
  start_sinatra
  scan(
    project: 'SampleApp.xcodeproj',
    scheme: 'SampleAppScheme',
    testplan: 'SampleAppTestPlan',
    devices: ['iPhone 8']
  )
end
