From 411465073fa37c424596b8d195adbd1ea8ccb788 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Thu, 16 Feb 2017 23:26:24 +0100 Subject: [PATCH] Check code coverage of tests using coveralls --- .travis.yml | 3 +++ Gemfile | 5 +++++ spec/spec_helper.rb | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1c0c707..64b67e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,9 @@ rvm: jdk: - oraclejdk8 +env: + - COVERAGE=1 + matrix: allow_failures: - rvm: ruby-head diff --git a/Gemfile b/Gemfile index 9126931..ca49e45 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,8 @@ platforms :mri do # Complete Markdown package for yard gem 'redcarpet' end + +group :coverage do + gem 'simplecov', :require => false + gem 'coveralls', '~> 0.8.18', :require => false +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 76b84d0..4e4c291 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,25 @@ # This software may be modified and distributed under the terms # of the MIT license. See the LICENSE.txt file for details. +if ENV['COVERAGE'] + require 'simplecov' + require 'coveralls' + + if ENV['TRAVIS'] + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] + else + SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter + end + + SimpleCov.start do + project_name 'Rackstash' + add_filter '/spec/' + end +end + $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'rackstash'