-
Notifications
You must be signed in to change notification settings - Fork 567
Closed
Description
tl;dr:
Summary of results:
summary of issues | Spork | ||
---|---|---|---|
not running | running | ||
SimpleCov | top of Spork.prefork | works as expected | SimpleCov doesn't run |
top of Spork.each_run | always 0 LOC, 0% coverage | SimpleCov doesn't run |
I'm on an existing Rails project using Mongoid, Devise, RSpec, and Spork (0.9.0.rc5). Our spec/spec_helper.rb
looks like this:
require 'spork'
ENV["RAILS_ENV"] ||= 'test'
Spork.prefork do
require 'simplecov'
SimpleCov.start 'rails'
# trap mongoid
require 'rails/mongoid'
Spork.trap_class_method(Rails::Mongoid, :load_models)
# trap devise
require 'rails/application'
Spork.trap_method(Rails::Application, :reload_routes!)
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
DatabaseCleaner.strategy = :truncation
RSpec.configure do |config|
config.mock_with :rspec
config.before(:each) do
DatabaseCleaner.clean
end
end
end
Spork.each_run do
# reload factories
Factory.definition_file_paths = [
File.join(Rails.root, 'spec', 'factories')
]
Factory.find_definitions
end
This configuration will run SimpleCov when Spork is not running, and it produces the expected result. When Spork is running, no coverage message is shown.
If I move the require 'simplecov'; SimpleCov.start 'rails'
lines to the beginning of the Spork.each_run block, as SimpleCov's readme suggests, then when Spork is not running, I get this:
Coverage report generated for RSpec to /home/johnf/projects/<elided>/coverage. 0 / 0 LOC (0.0%) covered.
If Spork is running, then instead I get no coverage message, as before.
Metadata
Metadata
Assignees
Labels
No labels