From 940698d4316c75d661798021ef490a3670183b3f Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 6 Jul 2011 19:29:43 -0400 Subject: [PATCH] run on start --- README.md | 3 ++- Rakefile | 8 ++++++++ lib/guard/puppet.rb | 1 + spec/lib/guard/puppet_spec.rb | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 493da87..83404c6 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ It's assumed your configs are all in the current folder, which is the equivalent of `--confdir=$PWD` at the command line. Otherwise, there's not much use of using Guard with Puppet. :) -Three options so far: +Four options so far: +* `:run_on_start`: Apply Puppet configs when starting Guard (default: `false`) * `:verbose`: Show more output from Puppet (default: `true`) * `:debug`: Show even more output from Puppet (default: `false`) * `:manifest`: The main manifest file to run (default: `manifests/site.pp`) diff --git a/Rakefile b/Rakefile index c702cfc..8b6958f 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,9 @@ +include Rake::DSL if defined?(Rake::DSL) + require 'bundler/gem_tasks' +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) + +task :default => 'spec' + diff --git a/lib/guard/puppet.rb b/lib/guard/puppet.rb index ed27ab4..7ee2f22 100644 --- a/lib/guard/puppet.rb +++ b/lib/guard/puppet.rb @@ -11,6 +11,7 @@ module ::Guard @options = options UI.info "Guard::Puppet is watching for changes..." + run_all if options[:run_on_start] end def run_all diff --git a/spec/lib/guard/puppet_spec.rb b/spec/lib/guard/puppet_spec.rb index 70993d6..f659ee8 100644 --- a/spec/lib/guard/puppet_spec.rb +++ b/spec/lib/guard/puppet_spec.rb @@ -1,9 +1,31 @@ require 'spec_helper' require 'guard/puppet' +require 'guard/ui' +require 'guard/notifier' describe Guard::Puppet do let(:guard) { described_class.new } + describe '#initialize' do + before do + Guard::UI.stubs(:info) + end + + context 'without :run_on_start' do + it 'should not run anything' do + described_class.new + end + end + + context 'with :run_on_start' do + it 'should run Puppet on start' do + Guard::Puppet.any_instance.expects(:run_all) + + described_class.new([], { :run_on_start => true }) + end + end + end + describe '#run_all' do before do Guard::UI.stubs(:info)