summaryrefslogtreecommitdiffstats
path: root/spec/unit/interface/action_spec.rb
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-29 17:24:18 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-05-02 10:08:26 -0700
commitb23cc8abec1a1ec41b554b4e72f9a3c21feaf9da (patch)
treea0c8310b9a36b51c2566dfa7ef86ab421658ddd7 /spec/unit/interface/action_spec.rb
parent6815044fbc94c0d502b1061309d5aaeb8f791660 (diff)
downloadpuppet-b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da.tar.gz
puppet-b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da.tar.xz
puppet-b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da.zip
(#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@puppetlabs.com>
Diffstat (limited to 'spec/unit/interface/action_spec.rb')
-rwxr-xr-xspec/unit/interface/action_spec.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb
index f8102f435..e7996091f 100755
--- a/spec/unit/interface/action_spec.rb
+++ b/spec/unit/interface/action_spec.rb
@@ -150,6 +150,7 @@ 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
@@ -162,7 +163,10 @@ 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]
@@ -171,8 +175,8 @@ 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
@@ -186,7 +190,10 @@ 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)
@@ -215,7 +222,10 @@ 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
@@ -498,7 +508,9 @@ 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