Skip to content

Instantly share code, notes, and snippets.

@iorionda
Created October 14, 2016 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iorionda/dbc02ffaf1a0f49ac70e269f222ec88d to your computer and use it in GitHub Desktop.
Save iorionda/dbc02ffaf1a0f49ac70e269f222ec88d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'test_queue'
require 'test_queue/runner/rspec'
class RSpecTestQueueRunner < TestQueue::Runner::RSpec
def after_fork(num)
ENV.update('TEST_ENV_NUMBER' => num.to_s)
ActiveRecord::Base.configurations['test']['database'] << num.to_s
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Tasks::DatabaseTasks.drop_current
ActiveRecord::Tasks::DatabaseTasks.create_current
ActiveRecord::Tasks::DatabaseTasks.load_schema_current
end
def summarize
estatus = @completed.inject(0){ |s, worker| s + worker.status.exitstatus }
estatus = 255 if estatus > 255
exit(estatus)
end
def run_worker(iterator)
@run_worker_ret = super
end
def cleanup_worker
Kernel.exit @run_worker_ret if @run_worker_ret
end
end
RSpecTestQueueRunner.new.execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment