Skip to content

Instantly share code, notes, and snippets.

@pwelch
Last active October 27, 2015 17:14
Show Gist options
  • Save pwelch/9d4a1a6fc287a48f1a83 to your computer and use it in GitHub Desktop.
Save pwelch/9d4a1a6fc287a48f1a83 to your computer and use it in GitHub Desktop.
Rake tasks for testing .rb or .json files
# Testing tasks
namespace :test do
desc 'Runs ruby or jq syntax check on roles'
task :roles do
puts '===== Running ruby syntax check on roles'
Dir.foreach('roles/') do |file|
if file =~ /.rb$/
sh "ruby -c roles/#{file}"
elsif file =~ /.json$/
sh "cat roles/#{file} | jq . > /dev/null"
end
end
end
desc 'Runs ruby or jq syntax check on environments'
task :environments do
puts '===== Running ruby syntax check on environments'
Dir.foreach('environments/') do |file|
if file =~ /.rb$/
sh "ruby -c environments/#{file}"
elsif file =~ /.json$/
sh "cat environments/#{file} | jq . > /dev/null"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment