From b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Fri, 29 Apr 2011 17:24:18 -0700 Subject: (#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 --- spec/unit/interface_spec.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'spec/unit/interface_spec.rb') diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb index 27da39766..e28e55aac 100755 --- a/spec/unit/interface_spec.rb +++ b/spec/unit/interface_spec.rb @@ -146,6 +146,7 @@ describe Puppet::Interface do option "--foo" option "--bar" action :baz do + when_invoked { true } option "--quux" end end @@ -155,7 +156,10 @@ 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 @@ -163,8 +167,8 @@ 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] @@ -176,14 +180,14 @@ 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 -- cgit