Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add support for multiple guards being passed to init

  • Loading branch information...
commit 004723c88292a9965a11b4774664c27e4e82ae54 1 parent a6eff23
@jredville jredville authored
Showing with 15 additions and 6 deletions.
  1. +8 −6 lib/guard/cli.rb
  2. +7 −0 spec/guard/cli_spec.rb
View
14 lib/guard/cli.rb
@@ -127,7 +127,7 @@ def version
::Guard::UI.info "Guard version #{ ::Guard::VERSION }"
end
- 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'
+ desc 'init [GUARDS]', 'Generates a Guardfile at the current directory (if it is not already there) and adds all installed guards or the given GUARDS into it'
method_option :bare,
:type => :boolean,
@@ -137,24 +137,26 @@ def version
# Initializes the templates of all installed Guard pluginss and adds them
# to the `Guardfile` when no Guard name is passed. When passing
- # a Guard plugin name it does the same but only for that Guard plugin.
+ # Guard plugin names it does the same but only for those Guard plugins.
#
# @see Guard::Guard.initialize_template
# @see Guard::Guard.initialize_all_templates
#
- # @param [String] guard_name the name of the Guard plugin to initialize
+ # @param [Array<String>] guard_names the name of the Guard plugins to initialize
#
- def init(guard_name = nil)
+ def init(*guard_names)
verify_bundler_presence
::Guard::Guardfile.create_guardfile(:abort_on_existence => options[:bare])
return if options[:bare]
- if guard_name.nil?
+ if guard_names.empty?
::Guard::Guardfile::initialize_all_templates
else
- ::Guard::Guardfile.initialize_template(guard_name)
+ guard_names.each do |guard_name|
+ ::Guard::Guardfile.initialize_template(guard_name)
+ end
end
end
View
7 spec/guard/cli_spec.rb
@@ -184,6 +184,13 @@
subject.init
end
+ it 'initializes each passed template by delegating to Guardfile.initialize_template' do
+ Guard::Guardfile.should_receive(:initialize_template).with('rspec')
+ Guard::Guardfile.should_receive(:initialize_template).with('pow')
+
+ subject.init 'rspec','pow'
+ end
+
context 'when passed a guard name' do
it 'initializes the template of the passed Guard by delegating to Guardfile.initialize_template' do
Guard::Guardfile.should_receive(:initialize_template).with('rspec')
Please sign in to comment.
Something went wrong with that request. Please try again.