linux-baseline/Rakefile

45 lines
1.1 KiB
Ruby
Raw Normal View History

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'
require 'rubocop/rake_task'
2014-06-05 08:50:37 +00:00
# Rubocop
desc 'Run Rubocop lint checks'
task :rubocop do
RuboCop::RakeTask.new
end
# Lint the cookbook
desc 'Run linters'
task :run_all_linters => [:rubocop] # rubocop:disable Style/HashSyntax
# Serverspec tests
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
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|
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