2014-06-05 08:50:37 +00:00
|
|
|
require 'rake'
|
|
|
|
require 'rspec/core/rake_task'
|
2014-06-16 14:20:21 +00:00
|
|
|
require 'rubocop/rake_task'
|
2014-06-05 08:50:37 +00:00
|
|
|
|
2014-06-16 14:20:21 +00:00
|
|
|
# Rubocop
|
|
|
|
desc 'Run Rubocop lint checks'
|
|
|
|
task :rubocop do
|
|
|
|
Rubocop::RakeTask.new
|
|
|
|
end
|
|
|
|
|
|
|
|
# Lint the cookbook
|
|
|
|
desc "Run linters"
|
|
|
|
task :lint => [ :rubocop ]
|
|
|
|
|
|
|
|
# Serverspec tests
|
2014-06-05 08:50:37 +00:00
|
|
|
suites = Dir.glob('*').select{|entry| File.directory?(entry) }
|
|
|
|
|
|
|
|
class ServerspecTask < RSpec::Core::RakeTask
|
|
|
|
|
|
|
|
attr_accessor :target
|
|
|
|
|
|
|
|
def spec_command
|
|
|
|
|
|
|
|
if target.nil?
|
|
|
|
puts "specify either env TARGET_HOST or target_host="
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
cmd = super
|
|
|
|
"env TARGET_HOST=#{target} STANDALONE_SPEC=true #{cmd} --format documentation --no-profile"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :serverspec do
|
|
|
|
suites.each do |suite|
|
|
|
|
desc "Run serverspec suite #{suite}"
|
|
|
|
ServerspecTask.new(suite.to_sym) do |t|
|
|
|
|
t.rspec_opts = "--no-color --format html --out report.html" if ENV['format'] == 'html'
|
|
|
|
t.target = ENV['TARGET_HOST'] || ENV['target_host']
|
|
|
|
t.ruby_opts = "-I #{suite}/serverspec"
|
|
|
|
t.pattern = "#{suite}/serverspec/*_spec.rb"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|