From 9264526a7cd45c9ff5767bc6c85585eb19f01f63 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Fri, 15 Apr 2011 15:31:19 -0700 Subject: (#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 --- spec/unit/interface/action_builder_spec.rb | 11 +++++++++++ spec/unit/interface/action_manager_spec.rb | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'spec/unit/interface') 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) -- cgit