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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# frozen_string_literal: true
if ENV['COVERAGE'] == 'yes'
begin
require 'simplecov'
require 'simplecov-console'
rescue LoadError
raise 'Add the simplecov and simplecov-console gems to Gemfile to enable this task'
end
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console,
]
SimpleCov.start do
track_files 'lib/**/*.rb'
add_filter 'lib/puppetlabs_spec_helper/version.rb'
add_filter '/spec'
# do not track vendored files
add_filter '/vendor'
add_filter '/.vendor'
end
end
require 'fakefs/spec_helpers'
FakeFS::Pathname.class_eval do
def symlink?
File.symlink?(@path)
end
end
require 'puppetlabs_spec_helper/puppet_spec_helper'
require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
require 'puppetlabs_spec_helper/rake_tasks'
RSpec.shared_context 'with a rake task', type: :task do
subject(:task) { Rake::Task[task_name] }
include FakeFS::SpecHelpers
let(:task_name) { self.class.top_level_description.delete_prefix('rake ') }
end
# configure RSpec after including all the code
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.include_context 'with a rake task', type: :task
end
|