Skip to content

Commit 157fafa

Browse files
author
Roderik van der Veer
committed
Missing files
1 parent 13e7641 commit 157fafa

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Rakefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env rake
2+
3+
task :default => 'foodcritic'
4+
5+
desc "Runs foodcritic linter"
6+
task :foodcritic do
7+
Rake::Task[:prepare_sandbox].execute
8+
9+
if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
10+
sh "foodcritic -f any #{sandbox_path}"
11+
else
12+
puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
13+
end
14+
end
15+
16+
desc "Runs knife cookbook test"
17+
task :knife do
18+
Rake::Task[:prepare_sandbox].execute
19+
20+
sh "bundle exec knife cookbook test cookbook -c test/.chef/knife.rb -o #{sandbox_path}/../"
21+
end
22+
23+
task :prepare_sandbox do
24+
files = %w{*.md *.rb attributes definitions libraries files providers recipes resources templates}
25+
26+
rm_rf sandbox_path
27+
mkdir_p sandbox_path
28+
cp_r Dir.glob("{#{files.join(',')}}"), sandbox_path
29+
end
30+
31+
private
32+
def sandbox_path
33+
File.join(File.dirname(__FILE__), %w(tmp cookbooks cookbook))
34+
end

test/.chef/knife.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cache_type 'BasicFile'
2+
cache_options(:path => "#{ENV['HOME']}/.chef/checksums")

test/support/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
gem "chef", "~> 11.8.2"
4+
gem "foodcritic", "~> 3.0.3"

0 commit comments

Comments
 (0)