Created
March 24, 2015 16:54
-
-
Save nalabjp/76f219e18ff9794a0f17 to your computer and use it in GitHub Desktop.
rspec-rails + test-queue + simplecov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ENV['COVERAGE'] | |
require 'simplecov' | |
require 'simplecov-rcov' | |
SimpleCov.merge_timeout 3600 | |
SimpleCov.formatters = [ | |
SimpleCov::Formatter::HTMLFormatter, | |
SimpleCov::Formatter::RcovFormatter | |
] | |
SimpleCov.start 'rails' | |
end | |
RSpec.configure do |config| | |
config.before(:each) do | |
SimpleCov.command_name("rspec_#{Process.pid.to_s}#{ENV['TEST_ENV_NUMBER']}") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ENV['RAILS_ENV'] ||= 'test' | |
ENV['TEST_QUEUE_STATS'] ||= File.expand_path('../../tmp/.test_queue_stats', __FILE__) | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'test_queue' | |
require 'test_queue/runner/rspec' | |
class MyAppRSpecRunner < 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 | |
::RSpec.configure do |config| | |
config.add_formatter('RSpecJUnitFormatter', "spec/reports/test_queue_rspec_#{num}.xml") | |
end | |
SimpleCov.at_exit do | |
SimpleCov.result | |
exit! 0 | |
end | |
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 | |
MyAppRSpecRunner.new.execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle exec ruby -v | |
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14] | |
$ bundle exec rails -v | |
Rails 4.2.1.rc3 | |
$ bundle list | egrep ' rspec|test-queue|simplecov' | |
* rspec (3.1.0) | |
* rspec-activemodel-mocks (1.0.1) | |
* rspec-core (3.1.7) | |
* rspec-expectations (3.1.2) | |
* rspec-mocks (3.1.3) | |
* rspec-parameterized (0.1.3) | |
* rspec-rails (3.1.0) | |
* rspec-support (3.1.2) | |
* rspec_junit_formatter (0.2.0) | |
* simplecov (0.9.2) | |
* simplecov-html (0.9.0) | |
* simplecov-rcov (0.2.3) | |
* test-queue (0.2.12) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment