From 147365cba1aad4bbbfed60c3e7ebc5bbc1ffaaa1 Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 16 Dec 2013 23:11:39 +0100 Subject: [PATCH] update coverage and use coveralls.io --- .travis.yml | 1 + Gemfile | 4 +++- Gemfile.lock | 12 ++++++++++++ spec/support/coverage.rb | 24 ++++++++++++++++++------ 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 383dac1c..003c0985 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ rvm: - 1.9.3 services: - redis-server +env: COVERALLS=1 before_install: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" diff --git a/Gemfile b/Gemfile index ffb4ff0e..20469350 100644 --- a/Gemfile +++ b/Gemfile @@ -84,10 +84,12 @@ group :test do # webkit and poltergeist don't seem to work yet gem 'selenium-webdriver' gem 'database_cleaner' - gem 'simplecov', require: false # need to include rspec components before i18n-spec or rake fails in test environment gem 'rspec-core' gem 'rspec-expectations' gem 'rspec-rerun' gem 'i18n-spec' + # code coverage + gem 'simplecov', require: false + gem 'coveralls', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 66644fe2..ffb7da3e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,6 +102,12 @@ GEM execjs coffee-script-source (1.6.3) commonjs (0.2.7) + coveralls (0.7.0) + multi_json (~> 1.3) + rest-client + simplecov (>= 0.7) + term-ansicolor + thor daemons (1.1.9) database_cleaner (1.2.0) debug_inspector (0.0.2) @@ -248,6 +254,8 @@ GEM redis-namespace (~> 1.2) sinatra (>= 0.9.2) vegas (~> 0.1.2) + rest-client (1.6.7) + mime-types (>= 1.16) rspec (2.14.1) rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) @@ -306,6 +314,8 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.8) + term-ansicolor (1.2.2) + tins (~> 0.8) therubyracer (0.12.0) libv8 (~> 3.16.14.0) ref @@ -315,6 +325,7 @@ GEM rack (>= 1.0.0) thor (0.18.1) tilt (1.4.1) + tins (0.13.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) @@ -357,6 +368,7 @@ DEPENDENCIES client_side_validations client_side_validations-simple_form coffee-rails (~> 3.2.1) + coveralls daemons database_cleaner exception_notification diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index c67e3172..20bbdcf3 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -1,14 +1,26 @@ # optional test coverage # needs to be loaded first, e.g. add a require at top of spec_helper -if ENV['COVERAGE'] +if ENV['COVERAGE'] or ENV['COVERALLS'] require 'simplecov' + + # update coveralls.io on Travis CI + if ENV['COVERALLS'] + require 'coveralls' + SimpleCov.formatter = Coveralls::SimpleCov::Formatter + end + + # slightly tweaked coverage reporting + def cov_no_plugins(source_file, path) + source_file.filename =~ /#{path}/ and not source_file.filename =~ /\/lib\/foodsoft_.*\// + end SimpleCov.start do add_filter '/spec/' add_filter '/test/' - add_group 'Models', '/app/models/' - add_group 'Controllers', '/app/controllers/' - add_group 'Helpers', '/app/helpers/' - add_group 'Documents', '/app/documents/' - add_group 'Libraries', '/lib/' + add_group 'Models' do |s| cov_no_plugins s, '/app/models/' end + add_group 'Controllers' do |s| cov_no_plugins s, '/app/controllers/' end + add_group 'Helpers' do |s| cov_no_plugins s, '/app/helpers/' end + add_group 'Documents' do |s| cov_no_plugins s, '/app/documents/' end + add_group 'Libraries' do |s| cov_no_plugins s, '/lib/' end + add_group 'Plugins' do |s| s.filename =~ /\/lib\/foodsoft_.*\// end end end