-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
34 lines (31 loc) · 1.15 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = "./spec/**/*_spec.rb"
ENV['COVERAGE'] = 'true'
end
namespace :commitment do
task :configure_test_for_code_coverage do
ENV['COVERAGE'] = 'true'
end
task :code_coverage do
require 'json'
$stdout.puts "Checking code_coverage"
lastrun_filename = File.expand_path('../coverage/.last_run.json', __FILE__)
if File.exist?(lastrun_filename)
coverage_percentage = JSON.parse(File.read(lastrun_filename)).fetch('result').fetch('line').to_i
EXPECTED_COVERAGE_GOAL = 100
if coverage_percentage < EXPECTED_COVERAGE_GOAL
abort("ERROR: Code Coverage Goal Not Met:\n\t#{coverage_percentage}%\tExpected\n\t#{EXPECTED_COVERAGE_GOAL}%\tActual")
else
$stdout.puts "Code Coverage Goal Met (at least #{EXPECTED_COVERAGE_GOAL}% coverage)"
end
else
abort "Expected #{lastrun_filename} to exist for code coverage"
end
end
end
task(default: ['commitment:configure_test_for_code_coverage', :spec, 'commitment:code_coverage'])
task(build: :default)
task(release: :default)