-
Notifications
You must be signed in to change notification settings - Fork 54
/
Rakefile
60 lines (48 loc) · 1.38 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require 'bundler/gem_tasks'
Dir['tasks/**/*.rake'].each { |t| load t }
require 'cookstyle'
desc 'Run cookstyle against cookstyle'
task :style do
sh('bundle exec cookstyle')
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/cop/**/*.rb']
end
desc 'Run RSpec with code coverage'
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task['spec'].execute
end
desc 'Ensure that all cops are defined in the cookstyle.yml config'
task :validate_config do
require 'cookstyle'
require 'yaml' unless defined?(YAML)
status = 0
config = YAML.load_file('config/cookstyle.yml')
puts 'Checking that all cops are defined in config/cookstyle.yml:'
RuboCop::Cop::Chef.constants.each do |dep|
RuboCop::Cop::Chef.const_get(dep).constants.each do |cop|
unless config["Chef/#{dep}/#{cop}"]
puts "Error: Chef/#{dep}/#{cop} not found in config/cookstyle.yml"
status = 1
end
end
end
puts 'All Cops found in the config. Good work.' if status == 0
exit status
end
begin
require 'yard'
YARD::Rake::YardocTask.new(:docs)
rescue LoadError
puts 'yard is not available. bundle install first to make sure all dependencies are installed.'
end
task :console do
require 'irb'
require 'irb/completion'
ARGV.clear
IRB.start
end
task default: [:style, :spec, :validate_config]