Skip to content

Commit

Permalink
Fix simplecov and coveralls support.
Browse files Browse the repository at this point in the history
Since Vagrant (and thus this plugin) run under a separate process,
we need to trigger simplecov from within our plugin. We then have
to have coveralls retrieve and send the results. We accomplish this
by setting and environmental variable at the beginning of our tests
which then triggers simplecov at the top of our plugin. Coveralls is
then set up to merge the results (although there is only one set)
and submit the results under its own rake task.
  • Loading branch information
ergonlogic committed Mar 31, 2014
1 parent 4260731 commit 686747d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#service_name: travis-ci
service_name: travis-ci
10 changes: 7 additions & 3 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Since simplecov need to run in the same process as the code being annalized,
# we run initialize simplecov at the very beginning of our plugin. To only do
# so during tests, we wrap it in a check for an environment variable.
ENV['COVERAGE'] = 'true'
require 'coveralls'
Coveralls.wear!

require 'vagrant-yaml'
# Since simplecov is running under a separate process, we need to retrieve the
# results afterwards.
Coveralls.wear_merged!
require 'aruba/cucumber'
10 changes: 10 additions & 0 deletions lib/vagrant-yaml.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Since Vagrant starts under a different process from our tests, we need to
# initialize simplecov here, and make it available for coveralls to retrieve.
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.command_name "binary #{Process.pid}"
SimpleCov.root(File.expand_path('../../', __FILE__))
SimpleCov.start
end


require 'vagrant'
require 'vagrant-yaml/errors'
require 'vagrant-yaml/plugin'
Expand Down
5 changes: 3 additions & 2 deletions tasks/cucumber.rake
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require 'rubygems'
require 'cucumber'
require 'cucumber/rake/task'
require 'coveralls/rake/task'

desc 'Default task which runs all cucumber tests'
task :default => [:features]

Coveralls::RakeTask.new
task :default => [:features, 'coveralls:push']
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --no-source --format pretty"
end

0 comments on commit 686747d

Please sign in to comment.