Skip to content

Instantly share code, notes, and snippets.

@gonzalo-bulnes
Created April 5, 2015 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzalo-bulnes/f4eac16fa587b0cffd18 to your computer and use it in GitHub Desktop.
Save gonzalo-bulnes/f4eac16fa587b0cffd18 to your computer and use it in GitHub Desktop.
Add validation of an app.json file to a Ruby test suite (by defining a Rake task).
# Rakefile
namespace :app_json do
desc 'Validate the app.json manifest'
task :validate do
require 'rainbow'
# check if the app.json validator is available
`which app.json`
if $?.exitstatus != 0
abort <<-eos.gsub /^( |\t)+/, ""
The #{Rainbow('app.json').red} program is not available.
You may want to install it in order to validate the app.json file.
Try #{Rainbow('`npm install app.json --global`').yellow} (use `sudo` if necessary)
or see https://github.com/app-json/app.json for instructions.
eos
end
# perform validation
response = `app.json validate 2>&1`
# celebrate successful validation!
if response =~ /Your app.json file is valid!/
puts Rainbow(response.strip).green
else
puts Rainbow(response.strip).red
end
end
end
# ...
# task :default => [:spec, 'blueprint:verify', 'app_json:validate']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment