ljross ljross - 3 months ago 36
Ruby Question

coveralls badge not updating on github

$LOAD_PATH.unshift File.expand_path('../../lib', FILE)
require 'to-arff.rb'
require 'to-arff/sqlitedb'

I am trying to add code coverage via coveralls. I have added the gem in the gemfile:

gem 'coveralls', require: false


In the .coveralls.yml file I have added:

service_name: travis-pro


And my gemfile looks like this:

require 'sequel'
require 'coveralls'
require 'simplecov'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
Coveralls.wear!


In the travis ci job log I can see the code coverage updated and Coverage report was sent to Coveralls. But coveralls website doesn't update and the coverage is unknown. That's why the github page is not showing the updated coverage.
What am I doing wrong?

Answer

According to the coveralls doc,

The Coveralls.wear! must occur before any of your application code is required, so should be at the very top of your spec_helper.rb, test_helper.rb, or env.rb, etc.

So your gemfile should look like:

require 'coveralls'
Coveralls.wear!

require 'sequel'
require 'simplecov'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)

Now commit this change and make a git push and you should see code coverage updated.