Permalink
Browse files

Refactor travis tests and fix foodcritic failures

  • Loading branch information...
alistairstead committed Aug 23, 2012
1 parent 0da7c9f commit 2ab31d59f01457f4fa02510da0c4e1fecfeab212
View
@@ -0,0 +1,2 @@
+cache_type 'BasicFile'
+cache_options(:path => "#{ENV['HOME']}/.chef/checksums")
View
1 .rspec
@@ -0,0 +1 @@
+--color
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm use 1.9.3@chef-php-extra --create
View
@@ -1,7 +1,7 @@
language: ruby
-gemfile:
- - test/support/Gemfile.ci
rvm:
- 1.9.2
- 1.9.3
-script: BUNDLE_GEMFILE=test/support/Gemfile.ci bundle exec rake foodcritic
+script:
+ - bundle exec rake test
+
View
@@ -0,0 +1,7 @@
+source :rubygems
+
+gem 'chef'
+gem 'chefspec'
+gem 'fauxhai'
+gem 'foodcritic'
+gem 'rake'
View
@@ -0,0 +1,104 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ bunny (0.8.0)
+ chef (10.12.0)
+ bunny (>= 0.6.0)
+ erubis
+ highline (>= 1.6.9)
+ json (>= 1.4.4, <= 1.6.1)
+ mixlib-authentication (>= 1.1.0)
+ mixlib-cli (>= 1.1.0)
+ mixlib-config (>= 1.1.2)
+ mixlib-log (>= 1.3.0)
+ mixlib-shellout
+ moneta
+ net-ssh (~> 2.2.2)
+ net-ssh-multi (~> 1.1.0)
+ ohai (>= 0.6.0)
+ rest-client (>= 1.0.4, < 1.7.0)
+ treetop (~> 1.4.9)
+ uuidtools
+ yajl-ruby (~> 1.1)
+ chefspec (0.6.1)
+ chef (>= 0.9.12)
+ erubis
+ rspec (~> 2.10.0)
+ coderay (1.0.7)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ fauxhai (0.0.2)
+ chef
+ net-ssh
+ foodcritic (1.5.1)
+ erubis
+ gherkin (~> 2.11.1)
+ gist (~> 3.1.0)
+ nokogiri (= 1.5.0)
+ pry (~> 0.9.8.4)
+ rak (~> 1.4)
+ treetop (~> 1.4.10)
+ yajl-ruby (~> 1.1.0)
+ gherkin (2.11.2)
+ json (>= 1.4.6)
+ gist (3.1.0)
+ highline (1.6.13)
+ ipaddress (0.8.0)
+ json (1.6.1)
+ method_source (0.7.1)
+ mime-types (1.19)
+ mixlib-authentication (1.3.0)
+ mixlib-log
+ mixlib-cli (1.2.2)
+ mixlib-config (1.1.2)
+ mixlib-log (1.4.1)
+ mixlib-shellout (1.1.0)
+ moneta (0.6.0)
+ net-ssh (2.2.2)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
+ net-ssh-multi (1.1)
+ net-ssh (>= 2.1.4)
+ net-ssh-gateway (>= 0.99.0)
+ nokogiri (1.5.0)
+ ohai (6.14.0)
+ ipaddress
+ mixlib-cli
+ mixlib-config
+ mixlib-log
+ systemu
+ yajl-ruby
+ polyglot (0.3.3)
+ pry (0.9.8.4)
+ coderay (~> 1.0.5)
+ method_source (~> 0.7.1)
+ slop (>= 2.4.4, < 3)
+ rak (1.4)
+ rake (0.9.2.2)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.1)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.1)
+ slop (2.4.4)
+ systemu (2.5.2)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ uuidtools (2.1.3)
+ yajl-ruby (1.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ chef
+ chefspec
+ fauxhai
+ foodcritic
+ rake
View
68 Rakefile 100644 → 100755
@@ -1,25 +1,59 @@
-desc "Runs foodcritic"
+#!/usr/bin/env rake
+
+# Don't output shell commands for fileutils
+Rake::FileUtilsExt.verbose(false)
+
+# Helpers
+def sandbox_path
+ File.join(File.dirname(__FILE__), %W(tmp cookbooks #{cookbook_name}))
+end
+
+def cookbook_name
+ File.basename(File.dirname(__FILE__))
+end
+
+# test task
+desc 'Run the default tests'
+task :test => ['prepare_sandbox', 'knife', 'foodcritic']
+
+# default task (test)
+task :default => :test
+
+# knife test
+desc 'Runs knife cookbook test'
+task :knife do
+ Rake::Task[:prepare_sandbox].invoke
+
+ sh "bundle exec knife cookbook test #{cookbook_name} -o #{sandbox_path}/../"
+end
+
+# foodcritic
+desc 'Runs foodcritic 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)
+ Rake::Task[:prepare_sandbox].invoke
- sh "foodcritic --epic-fail any #{File.dirname(sandbox)}"
+ if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
+ if sh "foodcritic -C -f any #{sandbox_path}"
+ puts 'foodcritic tests passed!'
+ end
else
- STDERR.puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
+ puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
end
end
-task :default => "foodcritic"
-
-private
+# sandbox helper
+task :prepare_sandbox do
+ files = %w{*.md *.rb attributes definitions files providers recipes resources spec templates test}
-def prepare_foodcritic_sandbox(sandbox)
- files = %w{*.md *.rb attributes definitions files providers
-recipes resources templates}
+ rm_rf sandbox_path
+ mkdir_p sandbox_path
+ cp_r Dir.glob("{#{files.join(',')}}"), sandbox_path
+end
- rm_rf sandbox
- mkdir_p sandbox
- cp_r Dir.glob("{#{files.join(',')}}"), sandbox
- puts "\n\n"
-end
+# RSpec - this needs to be last!
+require 'rspec/core/rake_task'
+desc 'Run specs'
+RSpec::Core::RakeTask.new do |t|
+ Rake::Task[:prepare_sandbox].invoke
+ t.pattern = File.join(sandbox_path, 'spec/**/*_spec.rb')
+end
View
@@ -211,7 +211,7 @@ def manage_pecl_ini(name, action, directives, zend_extensions)
owner "root"
group "root"
mode "0644"
- variables(:name => name, :extensions => extensions, :directives => directives)
+ variables(:name => name, :directives => directives)
action action
end
end
View
@@ -19,7 +19,7 @@
include_recipe "chef-php-extra::pear"
-php_pear "PhpDocumentor" do
+chef_php_extra_pear "PhpDocumentor" do
version "1.4.4"
action :install
end
View
@@ -25,4 +25,7 @@
owner "root"
group "root"
mode "0644"
+ variables(
+ :params => node['php']
+ )
end
View
@@ -20,8 +20,8 @@
include_recipe "git"
directory "/tmp/phpredis" do
- owner "vagrant"
- group "vagrant"
+ owner "root"
+ group "root"
mode "0755"
action :create
end
View
@@ -34,4 +34,7 @@
template "#{node['php']['ext_conf_dir']}/xdebug.ini" do
mode "0644"
+ variables(
+ :params => node['xdebug'],
+ )
end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::PHPUnit' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::PHPUnit' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::PHP_CodeBrowser' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::PHP_CodeBrowser' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::PHP_CodeSniffer' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::PHP_CodeSniffer' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::PHP_Depend' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::PHP_Depend' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::PHP_PMD' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::PHP_PMD' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::PhpDocumentor' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::PhpDocumentor' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::default' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::default' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::development' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::development' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_dev' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_dev' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_gd' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_gd' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_imagick' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_imagick' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_mcrypt' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_mcrypt' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_mysql' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_mysql' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_soap' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_soap' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
View
@@ -0,0 +1,8 @@
+require 'chefspec'
+
+describe 'chef-php-extra::module_xml' do
+ let (:chef_run) { ChefSpec::ChefRunner.new.converge 'chef-php-extra::module_xml' }
+ it 'should do something' do
+ pending 'Your recipe examples go here.'
+ end
+end
Oops, something went wrong.

0 comments on commit 2ab31d5

Please sign in to comment.