summaryrefslogtreecommitdiffstats
path: root/spec/unit/interface/option_spec.rb
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-15 15:34:24 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-15 15:34:24 -0700
commit0d0318f9f0eadff7f9934d3d02a7081bba05164c (patch)
treedfc6b3d976ac5acf822846c272bdb4451b10aeba /spec/unit/interface/option_spec.rb
parent3fe01a34e8397c30a00e7d47b4ac0b93198e1fcf (diff)
parentd80500f42367fa30a00dc12ef4b32b55b350b1ca (diff)
downloadpuppet-0d0318f9f0eadff7f9934d3d02a7081bba05164c.tar.gz
puppet-0d0318f9f0eadff7f9934d3d02a7081bba05164c.tar.xz
puppet-0d0318f9f0eadff7f9934d3d02a7081bba05164c.zip
Merge branch 'feature/2.7.x/6978-face-and-action-options-should-have-hooks-for-various-actions' into 2.7.x
Diffstat (limited to 'spec/unit/interface/option_spec.rb')
-rwxr-xr-xspec/unit/interface/option_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/unit/interface/option_spec.rb b/spec/unit/interface/option_spec.rb
index 3bcd121e2..4c24dc940 100755
--- a/spec/unit/interface/option_spec.rb
+++ b/spec/unit/interface/option_spec.rb
@@ -72,4 +72,28 @@ describe Puppet::Interface::Option do
option.to_s.should == "foo-bar"
end
end
+
+ %w{before after}.each do |side|
+ describe "#{side} hooks" do
+ subject { Puppet::Interface::Option.new(face, "--foo") }
+ let :proc do Proc.new do :from_proc end end
+
+ it { should respond_to "#{side}_action" }
+ it { should respond_to "#{side}_action=" }
+
+ it "should set the #{side}_action hook" do
+ subject.send("#{side}_action").should be_nil
+ subject.send("#{side}_action=", proc)
+ subject.send("#{side}_action").should be_an_instance_of UnboundMethod
+ end
+
+ data = [1, "foo", :foo, Object.new, method(:hash), method(:hash).unbind]
+ data.each do |input|
+ it "should fail if a #{input.class} is added to the #{side} hooks" do
+ expect { subject.send("#{side}_action=", input) }.
+ to raise_error ArgumentError, /not a proc/
+ end
+ end
+ end
+ end
end