diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-21 10:44:18 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-21 12:46:49 +0200 |
commit | 7a0f4d3c905cc92880697deac365a6c596fd55a8 (patch) | |
tree | 7bdd5e0102d974f1920f4925180cc074d59dd504 /spec/simplecov_env.rb | |
parent | 8e5e668e1a0844ebafbfc8081d9f71a030feb1d6 (diff) | |
download | gitlab-ce-7a0f4d3c905cc92880697deac365a6c596fd55a8.tar.gz |
Introduce SimpleCovEnv singleton helper and use it
Diffstat (limited to 'spec/simplecov_env.rb')
-rw-r--r-- | spec/simplecov_env.rb | 71 |
1 files changed, 45 insertions, 26 deletions
diff --git a/spec/simplecov_env.rb b/spec/simplecov_env.rb index 112ca1b176a..6f8f7109e14 100644 --- a/spec/simplecov_env.rb +++ b/spec/simplecov_env.rb @@ -1,35 +1,54 @@ require 'simplecov' -SimpleCov.configure do - load_profile 'test_frameworks' - track_files '{app,lib}/**/*.rb' +module SimpleCovEnv + extend self - if ENV['CI_BUILD_NAME'] - coverage_dir "coverage/#{ENV['CI_BUILD_NAME']}" - command_name ENV['CI_BUILD_NAME'] + def start! + return unless ENV['SIMPLECOV'] + + configure_profile + configure_job + + SimpleCov.start end - if ENV['CI'] - SimpleCov.at_exit do - # In CI environment don't generate formatted reports - # Only generate .resultset.json - SimpleCov.result + def configure_job + SimpleCov.configure do + if ENV['CI_BUILD_NAME'] + coverage_dir "coverage/#{ENV['CI_BUILD_NAME']}" + command_name ENV['CI_BUILD_NAME'] + end + + if ENV['CI'] + SimpleCov.at_exit do + # In CI environment don't generate formatted reports + # Only generate .resultset.json + SimpleCov.result + end + end end end - add_filter '/vendor/ruby/' - add_filter 'config/initializers/' - - add_group 'Controllers', 'app/controllers' - add_group 'Models', 'app/models' - add_group 'Mailers', 'app/mailers' - add_group 'Helpers', 'app/helpers' - add_group 'Workers', %w(app/jobs app/workers) - add_group 'Libraries', 'lib' - add_group 'Services', 'app/services' - add_group 'Finders', 'app/finders' - add_group 'Uploaders', 'app/uploaders' - add_group 'Validators', 'app/validators' - - merge_timeout 7200 + def configure_profile + SimpleCov.configure do + load_profile 'test_frameworks' + track_files '{app,lib}/**/*.rb' + + add_filter '/vendor/ruby/' + add_filter 'config/initializers/' + + add_group 'Controllers', 'app/controllers' + add_group 'Models', 'app/models' + add_group 'Mailers', 'app/mailers' + add_group 'Helpers', 'app/helpers' + add_group 'Workers', %w(app/jobs app/workers) + add_group 'Libraries', 'lib' + add_group 'Services', 'app/services' + add_group 'Finders', 'app/finders' + add_group 'Uploaders', 'app/uploaders' + add_group 'Validators', 'app/validators' + + merge_timeout 7200 + end + end end |