Browse files

Add development scripts.

  • Loading branch information...
1 parent 812a1c3 commit 47444d76b02237f50e7ab7c187998accbc4a2b99 @calavera calavera committed Mar 3, 2013
Showing with 70 additions and 13 deletions.
  1. +3 −0 .gitignore
  2. +0 −4 Gemfile
  3. +18 −0 README.md
  4. +0 −9 Rakefile
  5. +3 −0 examples/simple-solo/solo.rb
  6. +3 −0 gemfile_chef_10
  7. +4 −0 gemfile_chef_11
  8. +11 −0 script/bootstrap
  9. +28 −0 script/test
View
3 .gitignore
@@ -17,3 +17,6 @@ test/version_tmp
tmp
.vagrant
examples/simple-solo/chef.log
+gemfile_chef_10.lock
+gemfile_chef_11.lock
+examples/simple-solo/cache
View
4 Gemfile
@@ -1,4 +0,0 @@
-source 'http://rubygems.org'
-
-# Specify your gem's dependencies in minitest-chef-handler.gemspec
-gemspec
View
18 README.md
@@ -154,6 +154,24 @@ and be treated like any other error in the Chef execution.
The instructions above have described how to use it in a Chef solo installation. If you want to distribute the handler to your Chef server check either the chef_handler cookbooks in the examples or [minitest-handler-cookbook](https://github.com/btm/minitest-handler-cookbook).
+## Development
+
+Minitest-chef-handler should work with versions 10.x and versions 11.x of Chef.
+
+There are just two commands that you need to know to hack on this library.
+
+1. Load both versions of Chef dependencies:
+
+```
+$ script/bootstrap
+```
+
+2. Run unit and integration tests agains both versions of Chef:
+
+```
+$ script/test
+```
+
## Copyright
Copyright (c) 2012 David Calavera. See LICENSE for details.
View
9 Rakefile
@@ -2,16 +2,7 @@
require "bundler/gem_tasks"
require "rake/testtask"
-desc 'Verify that nothing is broken against the simple solo example'
-task :test do
- Dir.chdir('./examples/simple-solo') do
- sh 'ruby -I../../lib -S chef-solo -c solo.rb -j dna.json'
- end
-end
-
Rake::TestTask.new do |t|
t.name = 'spec'
t.pattern = 'spec/**/*_spec.rb'
end
-
-task :default => [:spec, :test]
View
3 examples/simple-solo/solo.rb
@@ -1,7 +1,10 @@
require 'minitest-chef-handler'
path = File.expand_path('{test/test_*,spec/*_spec}.rb', File.dirname(__FILE__))
+cache = File.expand_path('cache', File.dirname(__FILE__))
report_handlers << MiniTest::Chef::Handler.new(:path => path)
cookbook_path File.expand_path('cookbooks', File.dirname(__FILE__))
log_location 'chef.log'
+cache_options({ :path => cache, :skip_expires => true })
+file_cache_path cache
View
3 gemfile_chef_10
@@ -0,0 +1,3 @@
+source 'http://rubygems.org'
+gemspec
+gem 'chef', '~> 10.8'
View
4 gemfile_chef_11
@@ -0,0 +1,4 @@
+source 'http://rubygems.org'
+gemspec
+gem 'chef', '~> 11'
+
View
11 script/bootstrap
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+
+puts "-> Configuring Bundler with Chef 10 dependency."
+ENV['BUNDLE_GEMFILE'] = File.expand_path('../../gemfile_chef_10', __FILE__)
+
+system "bundle", "install"
+
+puts "-> Configuring Bundler with Chef 11 dependency."
+ENV['BUNDLE_GEMFILE'] = File.expand_path('../../gemfile_chef_11', __FILE__)
+
+system "bundle", "install"
View
28 script/test
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+
+ROOT = File.expand_path('../..', __FILE__)
+
+def test_all
+ Bundler.setup(:default)
+
+ system "bundle exec rake spec"
+
+ Dir.chdir('examples/simple-solo') do
+ system "bundle exec ruby -I#{File.expand_path('lib', ROOT)} -S chef-solo -c solo.rb -j dna.json"
+ end
+end
+
+puts '-> Testing with Chef 10'
+
+ENV['BUNDLE_GEMFILE'] = File.expand_path('gemfile_chef_10', ROOT)
+
+require "rubygems"
+require "bundler/setup"
+
+test_all
+
+puts '-> Testing with Chef 11'
+
+ENV['BUNDLE_GEMFILE'] = File.expand_path('gemfile_chef_11', ROOT)
+
+test_all

0 comments on commit 47444d7

Please sign in to comment.