diff options
| author | Luke Kanies <luke@madstop.com> | 2009-04-06 18:56:27 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-04-22 14:39:35 +1000 |
| commit | be30a618272d9828f90f5e726a23021be3b23221 (patch) | |
| tree | 591c714beb292cc81c278ef481d2262daede2629 /spec | |
| parent | 863c50b1273a7fa48d74fb74948938214b45967c (diff) | |
| download | puppet-be30a618272d9828f90f5e726a23021be3b23221.tar.gz puppet-be30a618272d9828f90f5e726a23021be3b23221.tar.xz puppet-be30a618272d9828f90f5e726a23021be3b23221.zip | |
Adding a common Settings method for setting values
We were previously missing some hooks for settings set
via the command-line, because different code paths were
being used.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/settings.rb | 16 |
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 }}) |
