Permalink
Browse files

add travis-ci foodcritic test

  • Loading branch information...
1 parent 59c3cbb commit 5530469e071eb138ad62498c547a37e2351e4358 @bryanwb committed May 23, 2012
Showing with 35 additions and 19 deletions.
  1. +1 −0 .gitignore
  2. +6 −0 .travis.yml
  3. +24 −19 Rakefile
  4. +4 −0 test/support/Gemfile
View
@@ -1,2 +1,3 @@
*~
.vagrant
+tmp
View
@@ -0,0 +1,6 @@
+language: ruby
+gemfile:
+ - test/support/Gemfile
+rvm:
+ - 1.9.3
+script: BUNDLE_GEMFILE=test/support/Gemfile bundle exec rake foodcritic
View
@@ -1,24 +1,29 @@
-task :vagrant_test => [:vagrant_up, :vagrant_provision] do
- puts "testing with vagrant"
-end
+#!/usr/bin/env rake
-task :vagrant_up do
- require 'vagrant'
- puts "About to put vagrant up"
- env = Vagrant::Environment.new
- env.cli("up")
-end
+@cookbook = "ark"
+
+desc "Runs foodcritc linter"
+task :foodcritic do
+ if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
+ sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic}, @cookbook)
+ prepare_foodcritic_sandbox(sandbox)
-task :vagrant_provision do
- require 'vagrant'
- puts "About to put vagrant up"
- env = Vagrant::Environment.new
- env.cli("provision")
+ sh "foodcritic --epic-fail any #{File.dirname(sandbox)}"
+ else
+ puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
+ end
end
-task :vagrant_destroy do
- require 'vagrant'
- puts "Provisioning vagrant vm"
- env = Vagrant::Environment.new
- env.cli("destroy")
+task :default => 'foodcritic'
+
+private
+
+def prepare_foodcritic_sandbox(sandbox)
+ files = %w{*.md *.rb attributes definitions files providers
+ recipes resources templates}
+
+ rm_rf sandbox
+ mkdir_p sandbox
+ cp_r Dir.glob("{#{files.join(',')}}"), sandbox
+ puts "\n\n"
end
View
@@ -0,0 +1,4 @@
+source "https://rubygems.org"
+
+gem 'rake'
+gem 'foodcritic', :platforms => :ruby_19

0 comments on commit 5530469

Please sign in to comment.