diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-24 13:33:30 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-24 13:41:31 -0700 |
| commit | 633f63cdbc1d5630e546041bb0c1e714216158d0 (patch) | |
| tree | bb2706ed7c77ec0142eb13fa820c9371142792b0 /spec/unit/interface | |
| parent | b3c059e74b1900c80c0fb875b696b7c5e2b5448b (diff) | |
| download | puppet-633f63cdbc1d5630e546041bb0c1e714216158d0.tar.gz puppet-633f63cdbc1d5630e546041bb0c1e714216158d0.tar.xz puppet-633f63cdbc1d5630e546041bb0c1e714216158d0.zip | |
(#6833) support 'script' as a short form of 'action'
At the moment the action method is a fairly heavy tool: it provides a DSL, and
is designed to allow substantial metadata to be added to the action.
For some users this is low on value, since they just want to write a little
script that drives things a bit differently. Which there is substantial value
in the metadata, adding the capability to do these light-weight things quickly
is valid.
To meet this we add a script action; the contrast is:
action :foo do
# other metadata goes here
invoke do |args|
# method body goes here
end
end
script :bar do |args|
# method body goes here
end
# ...and if you want metadata, you have to add it in more ugly, procedural
# ways, which we are not going to encourage.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'spec/unit/interface')
| -rwxr-xr-x[-rw-r--r--] | spec/unit/interface/action_manager_spec.rb | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb index d1a7e31be..3aff7ac11 100644..100755 --- a/spec/unit/interface/action_manager_spec.rb +++ b/spec/unit/interface/action_manager_spec.rb @@ -19,6 +19,12 @@ describe Puppet::Interface::ActionManager do end end + it "should be able to define a 'script' style action" do + subject.script :bar do + "a bar is where beer is found" + end + end + it "should be able to list defined actions" do subject.action(:foo) do invoke { "something" } @@ -27,8 +33,21 @@ describe Puppet::Interface::ActionManager do invoke { "something" } end - subject.actions.should include(:bar) - subject.actions.should include(:foo) + subject.actions.should =~ [:foo, :bar] + end + + it "should list 'script' actions" do + subject.script :foo do "foo" end + subject.actions.should =~ [:foo] + end + + it "should list both script and normal actions" do + subject.action :foo do + invoke do "foo" end + end + subject.script :bar do "a bar is where beer is found" end + + subject.actions.should =~ [:foo, :bar] end it "should be able to indicate when an action is defined" do @@ -39,6 +58,11 @@ describe Puppet::Interface::ActionManager do subject.should be_action(:foo) end + it "should indicate an action is defined for script actions" do + subject.script :foo do "foo" end + subject.should be_action :foo + end + it "should correctly treat action names specified as strings" do subject.action(:foo) do invoke { "something" } |
