From 16badcd1b546d493807b776b647ec8c6ba4d07a3 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 27 Sep 2018 15:40:35 +0200 Subject: [PATCH] Setup Simplecov to have code coverage analysis This enables code coverage analysis when running specs in your dev environment. Simply run them as usual and you'll see a line like the following at the end of the output: Coverage report generated for RSpec to /home/pau/dev/openfoodnetwork/coverage Simply browse to coverage/index.html and the results in a web UI. This is a useful tool that helps you decide if the tests you added are enough or not. --- .gitignore | 1 + Gemfile | 1 + Gemfile.lock | 7 +++++++ spec/spec_helper.rb | 3 +++ 4 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 060eb24f85e..4c0d217d06b 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ libpeerconnection.log /config/application.yml node_modules vendor/bundle/ +coverage diff --git a/Gemfile b/Gemfile index 2b33c609930..9473e1b32b9 100644 --- a/Gemfile +++ b/Gemfile @@ -129,6 +129,7 @@ end group :test do gem 'webmock' + gem 'simplecov', require: false # See spec/spec_helper.rb for instructions #gem 'perftools.rb' end diff --git a/Gemfile.lock b/Gemfile.lock index a63804e6bf2..7866190d4a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -265,6 +265,7 @@ GEM devise (>= 2.1.0) diff-lcs (1.3) diffy (3.1.0) + docile (1.3.1) dry-inflector (0.1.2) em-websocket (0.5.1) eventmachine (>= 0.12.9) @@ -688,6 +689,11 @@ GEM shellany (0.0.1) shoulda-matchers (2.8.0) activesupport (>= 3.0.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) skylight (1.6.1) activesupport (>= 3.0.0) spinjs-rails (1.3) @@ -832,6 +838,7 @@ DEPENDENCIES sass-rails (~> 3.2.3) shoulda-matchers simple_form! + simplecov skylight (< 2.0) spinjs-rails spree! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 40dc6cd2565..328c2aaac30 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start 'rails' + require 'rubygems' # Require pry when we're not inside Travis-CI