Sha256: 02e22ee7ccebc26156e0d62c3bd779a368184467208d820e2fe3c89c2a10a75a

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

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('covered_percent').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)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gm-notepad-0.0.18 Rakefile