Skip to content

Instantly share code, notes, and snippets.

@aokolish
Last active December 13, 2015 22:08
Show Gist options
  • Save aokolish/4982244 to your computer and use it in GitHub Desktop.
Save aokolish/4982244 to your computer and use it in GitHub Desktop.
how to get simplecov results when running specs from zeus.
require 'simplecov'
SimpleCov.configure do
SimpleCov.refuse_coverage_drop
add_filter "/spec/"
add_filter "scraper.rb" # don't care that this is spaghetti code
add_filter "error_messages_helper.rb"
add_filter "/config/"
add_filter "controller"
SimpleCov.minimum_coverage 93
end
require 'zeus/rails'
class CustomPlan < Zeus::Rails
def test
require 'simplecov'
SimpleCov.start
# you may need to load other files...
Dir["#{Rails.root}/app/helpers/**/*.rb"].each { |f| load f }
super
end
end
Zeus.plan = CustomPlan.new
def zeus_running?
File.exists? '.zeus.sock'
end
if !zeus_running?
SimpleCov.start
end
{
"command": "ruby -rubygems -r./custom_plan -eZeus.go",
"plan": {
"boot": {
"default_bundle": {
"development_environment": {
"prerake": {"rake": []},
"runner": ["r"],
"console": ["c"],
"server": ["s"],
"generate": ["g"],
"destroy": ["d"],
"dbconsole": []
},
"test_environment": {
"test_helper": {"test": ["rspec", "testrb"]}
}
}
}
}
}
@aokolish
Copy link
Author

Unfortunately, if zeus is running and you run specs with something like bundle exec rspec spec this will not generate a correct coverage report. However, it works for these cases:

  1. zeus is running - zeus rspec spec
  2. no zeus running - bundle exec rspec spec

@aokolish
Copy link
Author

You can run zeus init to create zeus.json and custom_plan.rb. Then, modify them as above.

@marksim
Copy link

marksim commented Feb 19, 2013

I believe you can also check ENV['ZEUS_MASTER_FD'] to see if it is running inside a zeus process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment