From dcdca70726e0a7e5d3572e03918f320dbf294269 Mon Sep 17 00:00:00 2001 From: luccastera Date: Thu, 8 Feb 2024 19:00:52 +0100 Subject: [PATCH] Added simplecov to get spec coverage --- .gitignore | 2 ++ Gemfile | 5 +++++ Gemfile.lock | 11 +++++++++++ README.md | 2 +- spec/spec_helper.rb | 15 +++++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1d76be6..1ad6aef 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,7 @@ node_modules +coverage + # Ignore the build directory /app/assets/builds \ No newline at end of file diff --git a/Gemfile b/Gemfile index d8306da..3aa3ff7 100644 --- a/Gemfile +++ b/Gemfile @@ -83,6 +83,11 @@ group :development do gem 'annotate' end +group :test do + gem "simplecov" + gem "simplecov-tailwindcss" +end + # Used to soft delete records gem "discard" diff --git a/Gemfile.lock b/Gemfile.lock index 9198327..69a27d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,6 +97,7 @@ GEM diff-lcs (1.5.1) discard (1.3.0) activerecord (>= 4.2, < 8) + docile (1.4.0) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) @@ -276,6 +277,14 @@ GEM ruby2_keywords (0.0.5) shoulda-matchers (6.1.0) activesupport (>= 5.2.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov-tailwindcss (2.2.0) + simplecov (~> 0.16) + simplecov_json_formatter (0.1.4) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -346,6 +355,8 @@ DEPENDENCIES rubocop (~> 1.27.0) rubocop-rails shoulda-matchers + simplecov + simplecov-tailwindcss sprockets-rails stimulus-rails tailwindcss-rails diff --git a/README.md b/README.md index 0904eb4..57f8f05 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ To install and run the application locally: 1. `bin/rails db:migrate` 1. Edit your credentials/secrets using `bin/rails credentials:edit`. 1. Install foreman: `gem install foreman` -1. Run the specs with `bin/ci` +1. Run the specs with `bin/ci` and check spec coverage with `open coverage/index.html` 1. Start the application in development mode with `bin/dev` 1. Visit [http://localhost:3009/](http://localhost:3009) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 327b58e..b617b4d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,6 +11,21 @@ # a separate helper file that requires the additional dependencies and performs # the additional setup, and require it from the spec files that actually need # it. + +require 'simplecov' +require 'simplecov-tailwindcss' + +SimpleCov.start 'rails' do + enable_coverage :branch + primary_coverage :branch + minimum_coverage line: 80, branch: 75 + maximum_coverage_drop 5 + add_group 'Blueprints', 'app/blueprints' +end +SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::TailwindFormatter +]) + # # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config|