ENV['RORY_STAGE'] ||= ENV['RACK_ENV'] || 'development'

require 'bumbleworks/gui'

require File.expand_path(File.join('spec', 'fixtures', 'bumbleworks_config.rb'))
require File.expand_path(File.join('spec', 'support', 'process_testing_helpers.rb'))

Bumbleworks.start_worker!

Widget.truncate!
WidgetyFidget.truncate!

widget_processes = 20.times.collect do |i|
  Widget.new(i).launch_process('task_process')
end

5.times do |i|
  WidgetyFidget.new(i)
end

wp = Bumbleworks.launch!('waiting_process')

wait_until { wp.reload.trackers.count == 4 }

widget_processes.first.tasks.each do |t|
  t.complete
end

run Bumbleworks::Gui::RackApp

ENV['RORY_STAGE'] ||= ENV['RACK_ENV'] || 'development'

require 'bumbleworks/gui'

require File.expand_path(File.join('spec', 'fixtures', 'bumbleworks_config.rb'))
require File.expand_path(File.join('spec', 'support', 'process_testing_helpers.rb'))

Bumbleworks.start_worker!

Widget.truncate!
WidgetyFidget.truncate!

widget_processes = 20.times.collect do |i|
  Widget.new(i).launch_process('task_process')
end

5.times do |i|
  WidgetyFidget.new(i)
end

wp = Bumbleworks.launch!('waiting_process')

wait_until { wp.reload.trackers.count == 4 }

widget_processes.first.tasks.each do |t|
  t.complete
end

if ENV['MOUNT_AT']
  app = Rack::Builder.new do
    map ENV['MOUNT_AT'] do
      run Bumbleworks::Gui::RackApp
    end
  end
  run app
else
  run Bumbleworks::Gui::RackApp
end


Enable mounting manual testing server at path
Enable mounting manual testing server at path

(Use the MOUNT_AT env variable when launching the server)