From b22441de499e5e13171bd2b96f2a7525ed73bfd9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 18:24:19 +0200 Subject: [PATCH 01/11] Remove `codeclimate-test-reporter` gem --- Gemfile | 1 - Gemfile.lock | 3 --- 2 files changed, 4 deletions(-) diff --git a/Gemfile b/Gemfile index fe8498495..a0736a4d7 100644 --- a/Gemfile +++ b/Gemfile @@ -142,7 +142,6 @@ end group :test do gem 'database_cleaner' - gem 'codeclimate-test-reporter', "~> 1.0.0" gem 'simplecov' gem 'webmock' end diff --git a/Gemfile.lock b/Gemfile.lock index d4f0cf9fd..3969539a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -142,8 +142,6 @@ GEM xpath (~> 2.0) chronic (0.10.2) cliver (0.3.2) - codeclimate-test-reporter (1.0.8) - simplecov (<= 0.13) coderay (1.1.0) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -493,7 +491,6 @@ DEPENDENCIES bundler-audit cancancan (= 1.11.0) capybara - codeclimate-test-reporter (~> 1.0.0) coderay (= 1.1.0) coffee-rails (= 4.1.0) countries From f7a911bced5b128ff1527501860065dd3f465f8a Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 18:32:35 +0200 Subject: [PATCH 02/11] Use new Code Climate test reporter --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c536088e..47ef81f9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,14 @@ before_script: - "cp config/application-example.yml config/application.yml" - "cp config/database-travis.yml config/database.yml" - "RAILS_ENV=test bundle exec rake db:setup:all" + - "curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter" + - "chmod +x ./cc-test-reporter" + - "./cc-test-reporter before-build" script: - "RAILS_ENV=test bundle exec rspec" - "bundle exec rake test" -after_success: - - "bundle exec codeclimate-test-reporter" +after_script: + - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT" services: - postgresql addons: From 37458b8e41a7d148fb8aaa3393e94b9be17015fa Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 18:32:56 +0200 Subject: [PATCH 03/11] Remove unused key in travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47ef81f9a..5801ca1ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,4 +22,3 @@ services: - postgresql addons: postgresql: "9.4" - code_climate: From 25b36d3d3087a27bc23ee6dfcdaefb2dc50bf5fb Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 18:33:46 +0200 Subject: [PATCH 04/11] Remove RAILS_ENV from travis.yml Travis sets it to `test` by default --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5801ca1ba..795074687 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,12 @@ before_script: - "psql -c 'create database registry_api_log_test;' -U postgres" - "cp config/application-example.yml config/application.yml" - "cp config/database-travis.yml config/database.yml" - - "RAILS_ENV=test bundle exec rake db:setup:all" + - "bundle exec rake db:setup:all" - "curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter" - "chmod +x ./cc-test-reporter" - "./cc-test-reporter before-build" script: - - "RAILS_ENV=test bundle exec rspec" + - "bundle exec rspec" - "bundle exec rake test" after_script: - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT" From dc842696f2df3fc77cda3055cf2058df3d502386 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 18:53:28 +0200 Subject: [PATCH 05/11] Update simplecov gem --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3969539a0..74f9082da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -414,11 +414,11 @@ GEM thor (~> 0.14) selectize-rails (0.12.1) sexp_processor (4.8.0) - simplecov (0.10.0) + simplecov (0.15.1) docile (~> 1.1.0) - json (~> 1.8) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.2) simpleidn (0.0.7) sinatra (1.4.8) rack (~> 1.5) From 20cf72571403b87247055791523a8e15f75f6916 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 19:06:11 +0200 Subject: [PATCH 06/11] Do not require simplecov gem in Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a0736a4d7..32c21e21d 100644 --- a/Gemfile +++ b/Gemfile @@ -142,6 +142,6 @@ end group :test do gem 'database_cleaner' - gem 'simplecov' + gem 'simplecov', require: false gem 'webmock' end From 0b5d1c705dd42cdf5e42b7136c94876257011333 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 19:09:23 +0200 Subject: [PATCH 07/11] Move `SimpleCov.start` to the very top of spec_helper --- spec/spec_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 03ebbc9b3..aa5f02589 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,11 @@ -require 'webmock/rspec' -WebMock.disable_net_connect!(allow_localhost: true) - if ENV['TRAVIS'] require 'simplecov' SimpleCov.start end +require 'webmock/rspec' +WebMock.disable_net_connect!(allow_localhost: true) + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest From 3ae418b3608d588457e6a9e27cbd826caafd4b81 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 20:11:04 +0200 Subject: [PATCH 08/11] Use abstract name for ENV variable Code coverage report can be generated on any machine, not only on Travis instance. --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index aa5f02589..445bfc014 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,4 @@ -if ENV['TRAVIS'] +if ENV['COVERAGE'] require 'simplecov' SimpleCov.start end From 3759e8179b43633b5d5f37b90a2e631deba47f60 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 20:15:08 +0200 Subject: [PATCH 09/11] Generate code coverage report when running tests --- test/test_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 98d6dcf8e..5fa9381d0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,8 @@ +if ENV['COVERAGE'] + require 'simplecov' + SimpleCov.start +end + ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' From 480f915a4d8f9a7a4648c3448d9e846b94174859 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 21:15:51 +0200 Subject: [PATCH 10/11] Configure SimpleCov to use Rails config --- spec/spec_helper.rb | 2 +- test/test_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 445bfc014..8e93cb442 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ if ENV['COVERAGE'] require 'simplecov' - SimpleCov.start + SimpleCov.start 'rails' end require 'webmock/rspec' diff --git a/test/test_helper.rb b/test/test_helper.rb index 5fa9381d0..9dbc3e3bc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,6 @@ if ENV['COVERAGE'] require 'simplecov' - SimpleCov.start + SimpleCov.start 'rails' end ENV['RAILS_ENV'] ||= 'test' From 06321df413110706a7439876ece832a370eaa92c Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sun, 28 Jan 2018 21:35:20 +0200 Subject: [PATCH 11/11] Merge spec and test code coverage --- spec/spec_helper.rb | 1 + test/test_helper.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e93cb442..3e1825acb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ if ENV['COVERAGE'] require 'simplecov' + SimpleCov.command_name 'spec' SimpleCov.start 'rails' end diff --git a/test/test_helper.rb b/test/test_helper.rb index 9dbc3e3bc..137bf85d6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,6 @@ if ENV['COVERAGE'] require 'simplecov' + SimpleCov.command_name 'test' SimpleCov.start 'rails' end