diff --git a/lib/guard/dsl.rb b/lib/guard/dsl.rb index 0f572b9..f8d0fc3 100644 --- a/lib/guard/dsl.rb +++ b/lib/guard/dsl.rb @@ -81,11 +81,12 @@ module Guard # Evaluate the DSL methods in the `Guardfile`. # # @param [Hash] options the Guard options + # @option options [Array] groups the groups to evaluate # @option options [String] guardfile the path to a valid Guardfile # @option options [String] guardfile_contents a string representing the content of a valid Guardfile # @raise [ArgumentError] when options are not a Hash # - def evaluate_guardfile(options = { }) + def evaluate_guardfile(options = {}) raise ArgumentError.new('No option hash passed to evaluate_guardfile!') unless options.is_a?(Hash) @@options = options.dup @@ -140,9 +141,8 @@ module Guard exit 1 end - # Get the content to evaluate. - # - # @return [String] the content of the Guardfile. + # Get the content to evaluate and stores it into + # the options as :guardfile_contents. # def fetch_guardfile_contents if @@options[:guardfile_contents] @@ -263,7 +263,7 @@ module Guard # guard 'livereload' # end # - # @param [String] name the group's name called from the CLI + # @param [Symbol, String] name the group's name called from the CLI # @yield a block where you can declare several guards # # @see Dsl#guard @@ -273,7 +273,7 @@ module Guard @groups = @@options[:group] || [] name = name.to_sym - if guard_definition && (@groups.empty? || @groups.map(&:to_sym).include?(name)) + if block_given? && (@groups.empty? || @groups.map(&:to_sym).include?(name)) @current_group = name yield if block_given? diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb index 2050ee6..965cf58 100644 --- a/spec/guard/dsl_spec.rb +++ b/spec/guard/dsl_spec.rb @@ -220,16 +220,16 @@ describe Guard::Dsl do describe "#ignore_paths" do disable_user_config - + it "adds the paths to the listener's ignore_paths" do ::Guard.stub!(:listener).and_return(mock('Listener')) ::Guard.listener.should_receive(:ignore_paths).and_return(ignore_paths = ['faz']) - + subject.evaluate_guardfile(:guardfile_contents => "ignore_paths 'foo', 'bar'") ignore_paths.should == ['faz', 'foo', 'bar'] end end - + describe "#group" do disable_user_config