Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add initial support for testing with Travis CI

  • Loading branch information...
commit bfbd7b63d3e0f7697337f882961dbf3d0d4d2299 1 parent 02ee773
@phlipper authored
Showing with 42 additions and 0 deletions.
  1. +35 −0 Rakefile
  2. +2 −0  test/.chef/knife.rb
  3. +5 −0 test/support/Gemfile
View
35 Rakefile
@@ -0,0 +1,35 @@
+#!/usr/bin/env rake
+
+task :default => "foodcritic"
+
+desc "Runs foodcritic linter"
+task :foodcritic do
+ Rake::Task[:prepare_sandbox].execute
+
+ if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
+ sh "foodcritic -f any #{sandbox_path}"
+ else
+ puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
+ end
+end
+
+desc "Runs knife cookbook test"
+task :knife do
+ Rake::Task[:prepare_sandbox].execute
+
+ sh "bundle exec knife cookbook test cookbook -c test/.chef/knife.rb -o #{sandbox_path}/../"
+end
+
+task :prepare_sandbox do
+ files = %w{*.md *.rb attributes definitions libraries files providers recipes resources templates}
+
+ rm_rf sandbox_path
+ mkdir_p sandbox_path
+ cp_r Dir.glob("{#{files.join(",")}}"), sandbox_path
+end
+
+private
+
+def sandbox_path
+ File.join(File.dirname(__FILE__), %w[tmp cookbooks cookbook])
+end
View
2  test/.chef/knife.rb
@@ -0,0 +1,2 @@
+cache_type "BasicFile"
+cache_options(:path => "#{ENV["HOME"]}/.chef/checksums")
View
5 test/support/Gemfile
@@ -0,0 +1,5 @@
+source "https://rubygems.org"
+
+gem "rake"
+gem "foodcritic"
+gem "chef", "~> 10.12.0"
Please sign in to comment.
Something went wrong with that request. Please try again.