2013-07-25 13:59:55 +02:00
|
|
|
# optional test coverage
|
|
|
|
# needs to be loaded first, e.g. add a require at top of spec_helper
|
2013-12-16 23:11:39 +01:00
|
|
|
if ENV['COVERAGE'] or ENV['COVERALLS']
|
2013-07-25 13:59:55 +02:00
|
|
|
require 'simplecov'
|
2013-12-16 23:11:39 +01:00
|
|
|
|
|
|
|
# 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)
|
2023-05-12 13:01:12 +02:00
|
|
|
source_file.filename =~ /#{path}/ and !(source_file.filename =~ %r{/lib/foodsoft_.*/})
|
2013-12-16 23:11:39 +01:00
|
|
|
end
|
2013-07-25 13:59:55 +02:00
|
|
|
SimpleCov.start do
|
|
|
|
add_filter '/spec/'
|
|
|
|
add_filter '/test/'
|
2013-12-16 23:11:39 +01:00
|
|
|
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
|
2023-05-12 13:01:12 +02:00
|
|
|
add_group 'Plugins' do |s| s.filename =~ %r{/lib/foodsoft_.*/} end
|
2013-07-25 13:59:55 +02:00
|
|
|
end
|
|
|
|
end
|