summaryrefslogtreecommitdiffstats
path: root/spec/unit/interface/option_builder_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_builder_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_builder_spec.rb')
-rwxr-xr-xspec/unit/interface/option_builder_spec.rb53
1 files changed, 42 insertions, 11 deletions
diff --git a/spec/unit/interface/option_builder_spec.rb b/spec/unit/interface/option_builder_spec.rb
index fae48324e..b32b316f6 100755
--- a/spec/unit/interface/option_builder_spec.rb
+++ b/spec/unit/interface/option_builder_spec.rb
@@ -8,22 +8,53 @@ describe Puppet::Interface::OptionBuilder do
should be_an_instance_of Puppet::Interface::Option
end
- describe "when using the DSL block" do
- it "should work with an empty block" do
- option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
- # This block deliberately left blank.
- end
+ it "should work with an empty block" do
+ option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ # This block deliberately left blank.
+ end
- option.should be_an_instance_of Puppet::Interface::Option
+ option.should be_an_instance_of Puppet::Interface::Option
+ end
+
+ it "should support documentation declarations" do
+ text = "this is the description"
+ option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ desc text
end
+ option.should be_an_instance_of Puppet::Interface::Option
+ option.desc.should == text
+ end
- it "should support documentation declarations" do
- text = "this is the description"
+ context "before_action hook" do
+ it "should support a before_action hook" do
option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
- desc text
+ before_action do |a,b,c| :whatever end
end
- option.should be_an_instance_of Puppet::Interface::Option
- option.desc.should == text
+ option.before_action.should be_an_instance_of UnboundMethod
+ end
+
+ it "should fail if the hook block takes too few arguments" do
+ expect do
+ Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ before_action do |one, two| true end
+ end
+ end.to raise_error ArgumentError, /takes three arguments/
+ end
+
+ it "should fail if the hook block takes too many arguments" do
+ expect do
+ Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ before_action do |one, two, three, four| true end
+ end
+ end.to raise_error ArgumentError, /takes three arguments/
+ end
+
+ it "should fail if the hook block takes a variable number of arguments" do
+ expect do
+ Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ before_action do |*blah| true end
+ end
+ end.to raise_error ArgumentError, /takes three arguments/
end
end
end