Permalink
Browse files

Add an option to generate a bare Guardfile to keep the old functionality

  • Loading branch information...
1 parent d2cdff9 commit 360080f2f6e10f8e516d6df14c4d5e6d44c3e96a @Maher4Ever committed Jan 27, 2012
Showing with 22 additions and 2 deletions.
  1. +9 −1 lib/guard/cli.rb
  2. +13 −1 spec/guard/cli_spec.rb
View
@@ -102,7 +102,13 @@ def version
::Guard::UI.info "Guard version #{ ::Guard::VERSION }"
end
- desc 'init [GUARD]', 'Generates a Guardfile at the current working directory, or insert the given GUARD to an existing Guardfile'
+ desc 'init [GUARD]', 'Generates a Guardfile at the current directory (if it is not already there) and adds all installed guards or the given GUARD into it'
+
+ method_option :bare,
+ :type => :boolean,
+ :default => false,
+ :aliases => '-b',
+ :banner => 'Generate a bare Guardfile without adding any installed guard into it'
# Initializes the templates of all installed Guards and adds them
# to the `Guardfile` when no Guard name is passed. When passed
@@ -118,6 +124,8 @@ def init(guard_name = nil)
::Guard.create_guardfile
+ return if options[:bare]
+
if guard_name.nil?
::Guard::initialize_all_templates
else
@@ -137,7 +137,7 @@
end
end
- describe '#init', :focus do
+ describe '#init' do
before do
::Guard.stub(:create_guardfile)
::Guard.stub(:initialize_all_templates)
@@ -160,6 +160,18 @@
end
end
+ context 'with the bare option' do
+ before { subject.should_receive(:options).and_return({:bare => true}) }
+
+ it 'Only creates the Guardfile and does not initialize any Guard template' do
+ ::Guard.should_receive(:create_guardfile)
+ ::Guard.should_not_receive(:initialize_template)
+ ::Guard.should_not_receive(:initialize_all_templates)
+
+ subject.init
+ end
+ end
+
context 'when running with Bundler' do
before do
@bundler_env = ENV['BUNDLE_GEMFILE']

0 comments on commit 360080f

Please sign in to comment.