2014-06-22 13:00:34 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
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
|
2014-06-22 10:57:10 +00:00
|
|
|
RuboCop::RakeTask.new
|
2014-06-16 14:20:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Lint the cookbook
|
2014-06-22 10:57:10 +00:00
|
|
|
desc 'Run linters'
|
|
|
|
task :run_all_linters => [:rubocop] # rubocop:disable Style/HashSyntax
|
2014-06-16 14:20:21 +00:00
|
|
|
|
|
|
|
# Serverspec tests
|
2014-06-22 10:57:10 +00:00
|
|
|
suites = Dir.glob('*').select { |entry| File.directory?(entry) }
|
2014-06-05 08:50:37 +00:00
|
|
|
|
|
|
|
class ServerspecTask < RSpec::Core::RakeTask
|
|
|
|
attr_accessor :target
|
|
|
|
|
|
|
|
def spec_command
|
2014-06-22 10:57:10 +00:00
|
|
|
if target.nil?
|
|
|
|
puts 'specify either env TARGET_HOST or target_host='
|
2014-06-05 08:50:37 +00:00
|
|
|
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|
|
2014-06-22 10:57:10 +00:00
|
|
|
t.rspec_opts = '--no-color --format html --out report.html' if ENV['format'] == 'html'
|
2014-06-05 08:50:37 +00:00
|
|
|
t.target = ENV['TARGET_HOST'] || ENV['target_host']
|
|
|
|
t.ruby_opts = "-I #{suite}/serverspec"
|
|
|
|
t.pattern = "#{suite}/serverspec/*_spec.rb"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|