R.I.Pienaar | 1 May 2011 10:34
Favicon
Gravatar

Re: feature 7225 against master


----- Original Message -----
> On Apr 24, 2011, at 5:27 AM, R.I.Pienaar wrote:
> 
> > Sorry for the patch spam, had to make some tweaks to this:
> > 
> > - fix the commit message to reflect the code change better
> > - tweak the queue name used for the identity queue to make writing
> > ACLs easier
> 
> This is a significant change in how mcollective can be used, right?
>  Before this it only worked with topic queues and now it can have
> per-host individual queues?
> 
> This seems like a great addition, and I have some ideas of how it'll
> change usage, but can you provide some examples of what you expect
> people to do with it?

Yes, its a big change, the tl;dr version is I want to make mc appropriate
as a transport for BPM job systems and the like.

The challenge isnt in making a point to point job system this has been done
many times over, the challenge is in marrying the current discovery, 
broadcast and basic technology that makes MC unique with such a P2P system
that they compliment each other.  I can build a solid point to point system 
that shares Authentication, Authorization and Auditing and of course also
code you wrote in the RPC layer with the current broadcast system, its
the marriage that is important.

The improvements you gain from this work fall in various categories:
(Continue reading)

R.I.Pienaar | 1 May 2011 15:28
Favicon
Gravatar

[PATCH/mcollective 1/1] 7246 - add the ability to add the priority to JMS messages

Add a plugin.stomp.priority option that will be used by recent
versions of ActiveMQ to prioritize our messages over others.

Signed-off-by: R.I.Pienaar <rip <at> devco.net>
---
Local-branch: feature/master/7246_stomp_priority
 plugins/mcollective/connector/stomp.rb       |   19 +++++++++++++++++--
 website/changelog.md                         |    1 +
 website/reference/plugins/connector_stomp.md |    9 +++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/plugins/mcollective/connector/stomp.rb b/plugins/mcollective/connector/stomp.rb
index 17ef337..2806ed4 100644
--- a/plugins/mcollective/connector/stomp.rb
+++ b/plugins/mcollective/connector/stomp.rb
 <at>  <at>  -51,6 +51,13  <at>  <at>  module MCollective
         #     plugin.stomp.pool.max_reconnect_attempts = 0
         #     plugin.stomp.pool.randomize = false
         #     plugin.stomp.pool.timeout = -1
+        #
+        # For versions of ActiveMQ that supports message priorities
+        # you can set a priority, this will cause a "priority" header
+        # to be emitted if present:
+        #
+        #     plugin.stomp.priority = 4
+        #
         class Stomp<Base
             attr_reader :connection

 <at>  <at>  -72,6 +79,7  <at>  <at>  module MCollective
(Continue reading)

Stefan Schulte | 1 May 2011 15:50

Instances method of mountprovider is broken


Running »puppet resource mount« always reports :unmounted because the
instances method never takes the actual mountstate into account. The
bug was introduced while fixing #4914 (probably 9f40608 because
the retrieve method of the mounttype changed)

The first patch shows the actual misbehaviour.
The second patch fixes the issue.

The patch is based on 2.7.x but the bug also exists in 2.6.7.

-Stefan

--

-- 
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev <at> googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Stefan Schulte | 1 May 2011 15:50

[PATCH/puppet 2/2] (#7300) Fix instances method of mount provider

The instance method now behaves like the prefetch method: After parsing
/etc/(v)fstab run mount to update the ensure state from either
:unmounted to :mounted and from :absent to :ghost

Signed-off-by: Stefan Schulte <stefan.schulte <at> taunusstein.net>
---
Local-branch: ticket/2.7.x/7300
 lib/puppet/provider/mount/parsed.rb |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb
index 11c5e21..13613a9 100755
--- a/lib/puppet/provider/mount/parsed.rb
+++ b/lib/puppet/provider/mount/parsed.rb
 <at>  <at>  -47,6 +47,24  <at>  <at>  Puppet::Type.type(:mount).provide(
     end
   end

+  def self.instances
+    providers = super
+    mounts = mountinstances.dup
+
+    # Update fstab entries that are mounted
+    providers.each do |prov|
+      if mounts.delete({:name => prov.get(:name), :mounted => :yes}) then
+        prov.set(:ensure => :mounted)
+      end
+    end
+
+    # Add mounts that are not in fstab but mounted
(Continue reading)

Stefan Schulte | 1 May 2011 15:50

[PATCH/puppet 1/2] (#7300) Add specs for the mount provider

Add specs to demonstrate that the instances method is currently broken
because it does not take the actual mountstate into account.

As a result running "puppet resource mount" on the commandline will
report every mount that appears in /etc/(v)fstab as unmounted.

Signed-off-by: Stefan Schulte <stefan.schulte <at> taunusstein.net>
---
Local-branch: ticket/2.7.x/7300
 spec/unit/provider/mount/parsed_spec.rb |   41 +++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 0293e07..2e1e1e9 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
 <at>  <at>  -193,6 +193,47  <at>  <at>  FSTAB

   my_fixtures('*.fstab').each do |fstab|
     platform = File.basename(fstab, '.fstab')
+
+    describe "when calling instances on #{platform}" do
+      before :each do
+        if Facter[:operatingsystem] == "Solaris" then
+          platform == 'solaris' or
+            pending "We need to stub the operatingsystem fact at load time, but can't"
+        else
+          platform != 'solaris' or
+            pending "We need to stub the operatingsystem fact at load time, but can't"
+        end
(Continue reading)

Stefan Schulte | 1 May 2011 22:33

[PATCH/puppet 1/1] (#7299) rake spec should work when net/ssh is absent


Signed-off-by: Stefan Schulte <stefan.schulte <at> taunusstein.net>
---
Local-branch: ticket/2.7.x/7299
 .../unit/util/network_device/transport/ssh_spec.rb |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/spec/unit/util/network_device/transport/ssh_spec.rb b/spec/unit/util/network_device/transport/ssh_spec.rb
index 18d22a9..60cf297 100755
--- a/spec/unit/util/network_device/transport/ssh_spec.rb
+++ b/spec/unit/util/network_device/transport/ssh_spec.rb
 <at>  <at>  -2,9 +2,10  <at>  <at> 

 require File.dirname(__FILE__) + '/../../../../spec_helper'

-require 'puppet/util/network_device/transport/ssh'
+require 'puppet/util/network_device/transport/ssh' if Puppet.features.ssh?

-describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => Puppet.features.ssh? do
+# Use a string as description because the class is unknown if features.ssh? is false
+describe 'Puppet::Util::NetworkDevice::Transport::Ssh', :if => Puppet.features.ssh? do

   before(:each) do
      <at> transport = Puppet::Util::NetworkDevice::Transport::Ssh.new()
-- 
1.7.5.rc3

--

-- 
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev <at> googlegroups.com.
(Continue reading)

Pradeep Jindal | 2 May 2011 09:20
Picon

node regexp should expose the matched node in the current scope

Hey Guys,


I just started using puppet and i like it, when i came across construct "node <regexp> { }" I was expecting that whichever node (host) matches that regexp will be exposed in the current scope using $name, but that was not the case. Having that allows us to write node constructs like this:

====
node /web[0-9]{4}.*/ {
    include webserver
    if $name == "web1000.example.com" {
        include not_serving
    }
}
====

this removes a lot of noise (and repetition) from the manifest file. Having said that I think whatsoever "regexp node construct" stores in $name by default is not that useful. I have a tiny patch (created against 2.6.7, but is valid for 2.6.8 too) for just that. Can this be the default behavior in puppet?

attached is the patch.

- praddy

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev <at> googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Attachment (node_regexp.patch): application/octet-stream, 1156 bytes
Luke Kanies | 2 May 2011 18:40
Gravatar

Re: [PATCH/puppet 1/1] (#7299) rake spec should work when net/ssh is absent

On May 1, 2011, at 1:33 PM, Stefan Schulte wrote:

> 
> Signed-off-by: Stefan Schulte <stefan.schulte <at> taunusstein.net>
> ---
> Local-branch: ticket/2.7.x/7299
> .../unit/util/network_device/transport/ssh_spec.rb |    5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/spec/unit/util/network_device/transport/ssh_spec.rb b/spec/unit/util/network_device/transport/ssh_spec.rb
> index 18d22a9..60cf297 100755
> --- a/spec/unit/util/network_device/transport/ssh_spec.rb
> +++ b/spec/unit/util/network_device/transport/ssh_spec.rb
>  <at>  <at>  -2,9 +2,10  <at>  <at> 
> 
> require File.dirname(__FILE__) + '/../../../../spec_helper'
> 
> -require 'puppet/util/network_device/transport/ssh'
> +require 'puppet/util/network_device/transport/ssh' if Puppet.features.ssh?

If possible, it's better to have this included class do the feature testing - it's problematic if a given
file throws exceptions if it's included.

If the class in this file inherits from a required class, obviously you can't avoid this construct, but I'd
far prefer to have the test for the feature happen in the initialize() method.

> -describe Puppet::Util::NetworkDevice::Transport::Ssh, :if => Puppet.features.ssh? do
> +# Use a string as description because the class is unknown if features.ssh? is false
> +describe 'Puppet::Util::NetworkDevice::Transport::Ssh', :if => Puppet.features.ssh? do
> 
>   before(:each) do
>      <at> transport = Puppet::Util::NetworkDevice::Transport::Ssh.new()
> -- 
> 1.7.5.rc3
> 
> -- 
> You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
> To post to this group, send email to puppet-dev <at> googlegroups.com.
> To unsubscribe from this group, send email to puppet-dev+unsubscribe <at> googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
> 

-- 
The most overlooked advantage to owning a computer is that if they foul
up there's no law against wacking them around a little.  -- Joe Martin
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   http://about.me/lak

--

-- 
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev <at> googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Andrew Forgue | 2 May 2011 18:02
Picon

Re: node regexp should expose the matched node in the current scope

Can't you just use if $hostname?

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev <at> googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
Daniel Pittman | 2 May 2011 19:19
Gravatar

[PATCH] (#7282) action without `when_invoked` should fail...

We used to let actions be declared without the `when_invoked` block, which was
usually a sign of either someone writing their method code direct in action
declaration, or someone forgetting to add their code at all.

This was just let silently by: the error only showed up when you finally tried
to invoke the action, and a NoMethod error was raised by the face.

...except for our own testing.  We took advantage of this a whole pile of
times in there; fixing the original UI issue means fixing all those too.

Reviewed-By: Nick Lewis <nick <at> puppetlabs.com>
---
 lib/puppet/interface/action.rb             |    5 +++-
 lib/puppet/interface/action_builder.rb     |    1 +
 spec/lib/puppet/face/huzzah.rb             |    2 +-
 spec/unit/interface/action_builder_spec.rb |   37 +++++++++++++++++++++++++---
 spec/unit/interface/action_manager_spec.rb |   16 +++++++----
 spec/unit/interface/action_spec.rb         |   24 +++++++++++++----
 spec/unit/interface_spec.rb                |   14 +++++++----
 7 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
index 0dbdd57..203d808 100644
--- a/lib/puppet/interface/action.rb
+++ b/lib/puppet/interface/action.rb
 <at>  <at>  -171,7 +171,8  <at>  <at>  class Puppet::Interface::Action
   # this stuff work, because it would have been cleaner.  Which gives you an
   # idea how motivated we were to make this cleaner.  Sorry.
   # --daniel 2011-03-31
-  attr_reader :positional_arg_count
+  attr_reader   :positional_arg_count
+  attr_accessor :when_invoked
   def when_invoked=(block)

     internal_name = "#{ <at> name} implementation, required on Ruby 1.8".to_sym
 <at>  <at>  -219,9 +220,11  <at>  <at>  WRAPPER
     if  <at> face.is_a?(Class)
        <at> face.class_eval do eval wrapper, nil, file, line end
        <at> face.define_method(internal_name, &block)
+       <at> when_invoked =  <at> face.instance_method(name)
     else
        <at> face.instance_eval do eval wrapper, nil, file, line end
        <at> face.meta_def(internal_name, &block)
+       <at> when_invoked =  <at> face.method(name).unbind
     end
   end

diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb
index afc49e9..0bf4f14 100644
--- a/lib/puppet/interface/action_builder.rb
+++ b/lib/puppet/interface/action_builder.rb
 <at>  <at>  -69,5 +69,6  <at>  <at>  class Puppet::Interface::ActionBuilder
      <at> face   = face
      <at> action = Puppet::Interface::Action.new(face, name)
     instance_eval(&block)
+     <at> action.when_invoked or raise ArgumentError, "actions need to know what to do when_invoked; please add
the block"
   end
 end
diff --git a/spec/lib/puppet/face/huzzah.rb b/spec/lib/puppet/face/huzzah.rb
index 2c2b7aa..6593d35 100755
--- a/spec/lib/puppet/face/huzzah.rb
+++ b/spec/lib/puppet/face/huzzah.rb
 <at>  <at>  -3,5 +3,5  <at>  <at>  Puppet::Face.define(:huzzah, '2.0.1') do
   copyright "Puppet Labs", 2011
   license   "Apache 2 license; see COPYING"
   summary "life is a thing for celebration"
-  action :bar do "is where beer comes from" end
+  script :bar do "is where beer comes from" end
 end
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb
index bf7afa7..e0d0ebe 100755
--- a/spec/unit/interface/action_builder_spec.rb
+++ b/spec/unit/interface/action_builder_spec.rb
 <at>  <at>  -7,7 +7,8  <at>  <at>  describe Puppet::Interface::ActionBuilder do
   let :face do Puppet::Interface.new(:puppet_interface_actionbuilder, '0.0.1') end

   it "should build an action" do
-    action = Puppet::Interface::ActionBuilder.build(nil, :foo) do
+    action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+      when_invoked do true end
     end
     action.should be_a(Puppet::Interface::Action)
     action.name.should == :foo
 <at>  <at>  -26,17 +27,25  <at>  <at>  describe Puppet::Interface::ActionBuilder do
       should raise_error("Action :foo must specify a block")
   end

+  it "should require an invocation block" do
+    expect {
+      Puppet::Interface::ActionBuilder.build(face, :foo) {}
+    }.to raise_error(/actions need to know what to do when_invoked; please add the block/)
+  end
+
   describe "when handling options" do
     it "should have a #option DSL function" do
       method = nil
       Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         method = self.method(:option)
       end
-      method.should be
+      method.should be_an_instance_of Method
     end

     it "should define an option without a block" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         option "--bar"
       end
       action.should be_option :bar
 <at>  <at>  -44,6 +53,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do

     it "should accept an empty block" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         option "--bar" do
           # This space left deliberately blank.
         end
 <at>  <at>  -55,6 +65,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
   context "inline documentation" do
     it "should set the summary" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         summary "this is some text"
       end
       action.summary.should == "this is some text"
 <at>  <at>  -64,13 +75,16  <at>  <at>  describe Puppet::Interface::ActionBuilder do
   context "action defaulting" do
     it "should set the default to true" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         default
       end
       action.default.should be_true
     end

     it "should not be default by, er, default. *cough*" do
-      action = Puppet::Interface::ActionBuilder.build(face, :foo) do end
+      action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
+      end
       action.default.should be_false
     end
   end
 <at>  <at>  -79,6 +93,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     it "should fail if no rendering format is given" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           when_rendering do true end
         end
       }.to raise_error ArgumentError, /must give a rendering format to when_rendering/
 <at>  <at>  -87,6 +102,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     it "should fail if no block is given" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           when_rendering :json
         end
       }.to raise_error ArgumentError, /must give a block to when_rendering/
 <at>  <at>  -95,6 +111,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     it "should fail if the block takes no arguments" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           when_rendering :json do true end
         end
       }.to raise_error ArgumentError, /when_rendering methods take one argument, the result, not/
 <at>  <at>  -103,6 +120,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     it "should fail if the block takes more than one argument" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           when_rendering :json do |a, b, c| true end
         end
       }.to raise_error ArgumentError, /when_rendering methods take one argument, the result, not/
 <at>  <at>  -111,6 +129,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     it "should fail if the block takes a variable number of arguments" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           when_rendering :json do |*args| true end
         end
       }.to raise_error(ArgumentError,
 <at>  <at>  -119,6 +138,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do

     it "should stash a rendering block" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         when_rendering :json do |a| true end
       end
       action.when_rendering(:json).should be_an_instance_of Method
 <at>  <at>  -127,6 +147,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     it "should fail if you try to set the same rendering twice" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           when_rendering :json do |a| true end
           when_rendering :json do |a| true end
         end
 <at>  <at>  -135,6 +156,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do

     it "should work if you set two different renderings" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         when_rendering :json do |a| true end
         when_rendering :yaml do |a| true end
       end
 <at>  <at>  -144,6 +166,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do

     it "should be bound to the face when called" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         when_rendering :json do |a| self end
       end
       action.when_rendering(:json).call(true).should == face
 <at>  <at>  -152,13 +175,16  <at>  <at>  describe Puppet::Interface::ActionBuilder do

   context "#render_as" do
     it "should default to nil (eg: based on context)" do
-      action = Puppet::Interface::ActionBuilder.build(face, :foo) do end
+      action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
+      end
       action.render_as.should be_nil
     end

     it "should fail if not rendering format is given" do
       expect {
         Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           render_as
         end
       }.to raise_error ArgumentError, /must give a rendering format to render_as/
 <at>  <at>  -167,6 +193,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
     Puppet::Network::FormatHandler.formats.each do |name|
       it "should accept #{name.inspect} format" do
         action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+          when_invoked do true end
           render_as name
         end
         action.render_as.should == name
 <at>  <at>  -175,6 +202,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do

     it "should accept :for_humans format" do
       action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+        when_invoked do true end
         render_as :for_humans
       end
       action.render_as.should == :for_humans
 <at>  <at>  -184,6 +212,7  <at>  <at>  describe Puppet::Interface::ActionBuilder do
       it "should fail if given #{input.inspect}" do
         expect {
           Puppet::Interface::ActionBuilder.build(face, :foo) do
+            when_invoked do true end
             render_as input
           end
         }.to raise_error ArgumentError, /#{input.inspect} is not a valid rendering format/
diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb
index 07d517c..5a479ad 100755
--- a/spec/unit/interface/action_manager_spec.rb
+++ b/spec/unit/interface/action_manager_spec.rb
 <at>  <at>  -94,7 +94,7  <at>  <at>  describe Puppet::Interface::ActionManager do
     end

     it "should be able to indicate when an action is defined" do
-      subject.action(:foo) { "something" }
+      subject.action(:foo) { when_invoked do true end }
       subject.should be_action(:foo)
     end
   end
 <at>  <at>  -218,25 +218,29  <at>  <at>  describe Puppet::Interface::ActionManager do

   describe "#action" do
     it 'should add an action' do
-      subject.action(:foo) {  }
+      subject.action(:foo) { when_invoked do true end }
       subject.get_action(:foo).should be_a Puppet::Interface::Action
     end

     it 'should support default actions' do
-      subject.action(:foo) { default }
+      subject.action(:foo) { when_invoked do true end; default }
       subject.get_default_action.should == subject.get_action(:foo)
     end

     it 'should not support more than one default action' do
-      subject.action(:foo) { default }
-      expect { subject.action(:bar) { default } }.should raise_error
+      subject.action(:foo) { when_invoked do true end; default }
+      expect { subject.action(:bar) {
+          when_invoked do true end
+          default
+        }
+      }.should raise_error /cannot both be default/
     end
   end

   describe "#get_action" do
     let :parent_class do
       parent_class = Class.new(Puppet::Interface)
-      parent_class.action(:foo) {}
+      parent_class.action(:foo) { when_invoked do true end }
       parent_class
     end

diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb
index f8102f4..e799609 100755
--- a/spec/unit/interface/action_spec.rb
+++ b/spec/unit/interface/action_spec.rb
 <at>  <at>  -150,6 +150,7  <at>  <at>  describe Puppet::Interface::Action do
     it "should support options with an empty block" do
       face = Puppet::Interface.new(:action_level_options, '0.0.1') do
         action :foo do
+          when_invoked do true end
           option "--bar" do
             # this line left deliberately blank
           end
 <at>  <at>  -162,7 +163,10  <at>  <at>  describe Puppet::Interface::Action do

     it "should return only action level options when there are no face options" do
       face = Puppet::Interface.new(:action_level_options, '0.0.1') do
-        action :foo do option "--bar" end
+        action :foo do
+          when_invoked do true end
+          option "--bar"
+        end
       end

       face.get_action(:foo).options.should =~ [:bar]
 <at>  <at>  -171,8 +175,8  <at>  <at>  describe Puppet::Interface::Action do
     describe "with both face and action options" do
       let :face do
         Puppet::Interface.new(:action_level_options, '0.0.1') do
-          action :foo do option "--bar" end
-          action :baz do option "--bim" end
+          action :foo do when_invoked do true end ; option "--bar" end
+          action :baz do when_invoked do true end ; option "--bim" end
           option "--quux"
         end
       end
 <at>  <at>  -186,7 +190,10  <at>  <at>  describe Puppet::Interface::Action do
         parent.option "--foo"
         child = parent.new(:inherited_options, '0.0.1') do
           option "--bar"
-          action :action do option "--baz" end
+          action :action do
+            when_invoked do true end
+            option "--baz"
+          end
         end

         action = child.get_action(:action)
 <at>  <at>  -215,7 +222,10  <at>  <at>  describe Puppet::Interface::Action do
     it_should_behave_like "things that declare options" do
       def add_options_to(&block)
         face = Puppet::Interface.new(:with_options, '0.0.1') do
-          action(:foo, &block)
+          action(:foo) do
+            when_invoked do true end
+            self.instance_eval &block
+          end
         end
         face.get_action(:foo)
       end
 <at>  <at>  -498,7 +508,9  <at>  <at>  describe Puppet::Interface::Action do
   it_should_behave_like "documentation on faces" do
     subject do
       face = Puppet::Interface.new(:action_documentation, '0.0.1') do
-        action :documentation do end
+        action :documentation do
+          when_invoked do true end
+        end
       end
       face.get_action(:documentation)
     end
diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb
index 27da397..e28e55a 100755
--- a/spec/unit/interface_spec.rb
+++ b/spec/unit/interface_spec.rb
 <at>  <at>  -146,6 +146,7  <at>  <at>  describe Puppet::Interface do
         option "--foo"
         option "--bar"
         action :baz do
+          when_invoked { true }
           option "--quux"
         end
       end
 <at>  <at>  -155,7 +156,10  <at>  <at>  describe Puppet::Interface do
     it "should fail when a face option duplicates an action option" do
       expect {
         subject.new(:action_level_options, '0.0.1') do
-          action :bar do option "--foo" end
+          action :bar do
+            when_invoked { true }
+            option "--foo"
+          end
           option "--foo"
         end
       }.should raise_error ArgumentError, /Option foo conflicts with existing option foo on/i
 <at>  <at>  -163,8 +167,8  <at>  <at>  describe Puppet::Interface do

     it "should work when two actions have the same option" do
       face = subject.new(:with_options, '0.0.1') do
-        action :foo do option "--quux" end
-        action :bar do option "--quux" end
+        action :foo do when_invoked { true } ; option "--quux" end
+        action :bar do when_invoked { true } ; option "--quux" end
       end

       face.get_action(:foo).options.should =~ [:quux]
 <at>  <at>  -176,14 +180,14  <at>  <at>  describe Puppet::Interface do
     let :parent do
       parent = Class.new(subject)
       parent.option("--inherited")
-      parent.action(:parent_action) do end
+      parent.action(:parent_action) do when_invoked { true } end
       parent
     end

     let :face do
       face = parent.new(:example, '0.2.1')
       face.option("--local")
-      face.action(:face_action) do end
+      face.action(:face_action) do when_invoked { true } end
       face
     end

-- 
1.7.5

--

-- 
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev <at> googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.


Gmane