summaryrefslogtreecommitdiffstats
path: root/spec/unit/interface
diff options
context:
space:
mode:
authorPieter van de Bruggen <pieter@puppetlabs.com>2011-04-15 15:31:19 -0700
committerPieter van de Bruggen <pieter@puppetlabs.com>2011-04-15 15:31:19 -0700
commit9264526a7cd45c9ff5767bc6c85585eb19f01f63 (patch)
tree4e8131a037b6352d0d3d52d7650dd9c1acf63465 /spec/unit/interface
parentba9bd88b8b60ebe567a6d78d70782610cc281213 (diff)
downloadpuppet-9264526a7cd45c9ff5767bc6c85585eb19f01f63.tar.gz
puppet-9264526a7cd45c9ff5767bc6c85585eb19f01f63.tar.xz
puppet-9264526a7cd45c9ff5767bc6c85585eb19f01f63.zip
(#7115) Enable default actions.
This also enables the 'help' action on the 'help' face to serve as a default action. Reviewed-By: Daniel Pittman Reviewed-By: Nick Lewis
Diffstat (limited to 'spec/unit/interface')
-rwxr-xr-xspec/unit/interface/action_builder_spec.rb11
-rwxr-xr-xspec/unit/interface/action_manager_spec.rb18
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb
index 5b04df900..8f29c8a7b 100755
--- a/spec/unit/interface/action_builder_spec.rb
+++ b/spec/unit/interface/action_builder_spec.rb
@@ -65,5 +65,16 @@ describe Puppet::Interface::ActionBuilder do
action.summary.should == "this is some text"
end
end
+
+ context "action defaulting" do
+ let :face do Puppet::Interface.new(:default_action, '0.0.1') end
+
+ it "should set the default to true" do
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
+ default
+ end
+ action.default.should == true
+ end
+ end
end
end
diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb
index c4b21eaac..387faa043 100755
--- a/spec/unit/interface/action_manager_spec.rb
+++ b/spec/unit/interface/action_manager_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
# This is entirely an internal class for Interface, so we have to load it instead of our class.
require 'puppet/interface'
+require 'puppet/face'
class ActionManagerTester
include Puppet::Interface::ActionManager
@@ -213,6 +214,23 @@ describe Puppet::Interface::ActionManager do
end
end
+ describe "#action" do
+ it 'should add an action' do
+ subject.action(:foo) { }
+ subject.get_action(:foo).should be_a Puppet::Interface::Action
+ end
+
+ it 'should support default actions' do
+ subject.action(:foo) { 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
+ end
+ end
+
describe "#get_action" do
let :parent_class do
parent_class = Class.new(Puppet::Interface)