summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/settings.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/util/settings.rb')
-rwxr-xr-xspec/unit/util/settings.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/spec/unit/util/settings.rb b/spec/unit/util/settings.rb
index c1d74a88b..6f92fae46 100755
--- a/spec/unit/util/settings.rb
+++ b/spec/unit/util/settings.rb
@@ -79,14 +79,14 @@ describe Puppet::Util::Settings do
end
it "should support a getopt-specific mechanism for turning booleans off" do
- @settings.handlearg("--no-bool")
+ @settings.handlearg("--no-bool", "")
@settings[:bool].should == false
end
it "should support a getopt-specific mechanism for turning booleans on" do
# Turn it off first
@settings[:bool] = false
- @settings.handlearg("--bool")
+ @settings.handlearg("--bool", "")
@settings[:bool].should == true
end
@@ -99,7 +99,7 @@ describe Puppet::Util::Settings do
it "should not clear other values when setting getopt-specific values" do
@settings[:myval] = "yay"
- @settings.handlearg("--no-bool")
+ @settings.handlearg("--no-bool", "")
@settings[:myval].should == "yay"
end
@@ -117,6 +117,16 @@ describe Puppet::Util::Settings do
values.should == %w{something}
end
+ it "should call passed blocks when values are set via the command line" do
+ values = []
+ @settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }})
+ values.should == []
+
+ @settings.handlearg("--hooker", "yay")
+
+ values.should == %w{yay}
+ end
+
it "should provide an option to call passed blocks during definition" do
values = []
@settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :call_on_define => true, :hook => lambda { |v| values << v }})