diff --git a/.gitignore b/.gitignore index 1e43942..eecf914 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,9 @@ yarn-debug.log* .yarn-integrity /config/deploy/config.yml + +# SimpleCov coverage output +/coverage + +# OS file +.DS_Store diff --git a/.travis.yml b/.travis.yml index 025f452..2a521e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,5 @@ install: script: - bundle exec rubocop - - bundle exec rails test - - bundle exec rails test:system + - bundle exec rails test NO_COVERAGE=1 + - bundle exec rails test:system NO_COVERAGE=1 diff --git a/Gemfile b/Gemfile index d9768ad..9f96957 100644 --- a/Gemfile +++ b/Gemfile @@ -81,6 +81,7 @@ group :test do gem 'launchy' gem "database_cleaner" + gem "simplecov", require: false end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index ee624a2..3326b9c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,6 +104,7 @@ GEM warden (~> 1.2.3) devise-i18n (1.6.2) devise (>= 4.4) + docile (1.3.1) erubi (1.7.1) execjs (2.7.0) factory_bot (4.10.0) @@ -134,6 +135,7 @@ GEM jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + json (2.1.0) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.6.0) @@ -259,6 +261,11 @@ GEM simple_form (4.0.1) actionpack (>= 5.0) activemodel (>= 5.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -339,6 +346,7 @@ DEPENDENCIES sass-rails (~> 5.0) selenium-webdriver simple_form (~> 4.0) + simplecov spring spring-watcher-listen (~> 2.0.0) turbolinks (~> 5) diff --git a/app/services/system_command.rb b/app/services/system_command.rb index c8f052c..c4d3e7a 100644 --- a/app/services/system_command.rb +++ b/app/services/system_command.rb @@ -34,6 +34,7 @@ class SystemCommand private + # :nocov: def call(cmd) pid, _, stdout, stderr = Open4.popen4 cmd _, status = Process.waitpid2 pid @@ -45,6 +46,7 @@ class SystemCommand stderr.read.strip, ) end + # :nocov: def escape_arg(arg) arg.to_s.gsub('"') { '\"' } diff --git a/test/test_helper.rb b/test/test_helper.rb index 2245dee..39e0d21 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,15 @@ ENV["RAILS_ENV"] ||= "test" +require "pry" + +if !ENV["NO_COVERAGE"] && (ARGV.empty? || ARGV.include?("test/test_helper.rb")) + require "simplecov" + SimpleCov.start "rails" do + add_group "Services", "app/services" + add_group "Notifier", "app/notifier" + add_group "Policies", "app/policies" + end +end + require_relative "../config/environment" require "rails/test_help"