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 | |
parent | 8e5e668e1a0844ebafbfc8081d9f71a030feb1d6 (diff) | |
download | gitlab-ce-7a0f4d3c905cc92880697deac365a6c596fd55a8.tar.gz |
Introduce SimpleCovEnv singleton helper and use it
Diffstat (limited to 'spec')
-rw-r--r-- | spec/simplecov_env.rb | 71 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 |
2 files changed, 47 insertions, 28 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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d2760d0ef28..4f3aacf55be 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ -require_relative 'simplecov_env' -SimpleCov.start if ENV['SIMPLECOV'] +require './spec/simplecov_env' +SimpleCovEnv.start! ENV["RAILS_ENV"] ||= 'test' |