diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-29 17:24:18 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-05-02 10:08:26 -0700 |
| commit | b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da (patch) | |
| tree | a0c8310b9a36b51c2566dfa7ef86ab421658ddd7 /spec/unit/interface_spec.rb | |
| parent | 6815044fbc94c0d502b1061309d5aaeb8f791660 (diff) | |
| download | puppet-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_spec.rb')
| -rwxr-xr-x | spec/unit/interface_spec.rb | 14 |
1 files changed, 9 insertions, 5 deletions
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 |
