Skip to content

Instantly share code, notes, and snippets.

@danielfone
Created July 22, 2017 02:35
Show Gist options
  • Save danielfone/58803d6e39dcc8b9187654a4912c57e1 to your computer and use it in GitHub Desktop.
Save danielfone/58803d6e39dcc8b9187654a4912c57e1 to your computer and use it in GitHub Desktop.
commit 918bc5d3a8323885e014fdb9f821503062692a90
Author: Daniel Fone <[email protected]>
Date: Sat Jul 22 14:30:53 2017 +1200
Add coverage requirements
diff --git a/coverage/.last_run.json b/coverage/.last_run.json
new file mode 100644
index 0000000..2f8e4cc
--- /dev/null
+++ b/coverage/.last_run.json
@@ -0,0 +1,5 @@
+{
+ "result": {
+ "covered_percent": 91.57
+ }
+}
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9ab56ec..c70e8d3 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,7 +1,7 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
-require 'simplecov'
-SimpleCov.start 'rails'
+
+require 'support/simplecov'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
diff --git a/spec/support/simplecov.rb b/spec/support/simplecov.rb
new file mode 100644
index 0000000..24fe9b7
--- /dev/null
+++ b/spec/support/simplecov.rb
@@ -0,0 +1,11 @@
+require 'simplecov'
+SimpleCov.start 'rails'
+
+RSpec.configure do |config|
+ changed_files = `git diff master --name-only && \
+ git diff --name-only && \
+ git diff --name-only --cached`.split
+
+ SimpleCov.refuse_coverage_drop
+ SimpleCov.add_group('Branch', changed_files)
+end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment