diff options
author | Chris Price <chris@puppetlabs.com> | 2012-10-17 15:50:02 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2012-10-17 15:50:02 -0700 |
commit | a5eebcfca0c1c8e8fb8130205a6ec623c8691326 (patch) | |
tree | 17a5bb35c8861a745786105eeaee2e7d8479e711 /spec/unit/puppet/provider/ini_setting | |
parent | 842b2f06b2d8bcd8a8e7ed00b2d388bc4ddf1db2 (diff) | |
parent | cda30a6ab9b6fa673ead091ab0b130cbc6e75dbc (diff) | |
download | puppet-inifile-a5eebcfca0c1c8e8fb8130205a6ec623c8691326.tar.gz puppet-inifile-a5eebcfca0c1c8e8fb8130205a6ec623c8691326.tar.bz2 |
Merge pull request #18 from cprice-puppet/feature/master/tweaks-to-setting-removal
Feature/master/tweaks to setting removal
Diffstat (limited to 'spec/unit/puppet/provider/ini_setting')
-rw-r--r-- | spec/unit/puppet/provider/ini_setting/ruby_spec.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb index 4062205..8b2f8e5 100644 --- a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb +++ b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb @@ -458,7 +458,79 @@ bar=baz ) end + end + + context "when ensuring that a setting is absent" do + let(:orig_content) { + <<-EOS +[section1] +; This is also a comment +foo=foovalue + +bar = barvalue +master = true +[section2] +foo= foovalue2 +baz=bazvalue +url = http://192.168.1.1:8080 +[section:sub] +subby=bar + #another comment + ; yet another comment +EOS + } + + it "should remove a setting that exists" do + resource = Puppet::Type::Ini_setting.new(common_params.merge( + :section => 'section1', :setting => 'foo', :ensure => 'absent')) + provider = described_class.new(resource) + provider.exists?.should be_true + provider.destroy + validate_file(<<-EOS +[section1] +; This is also a comment + +bar = barvalue +master = true +[section2] + +foo= foovalue2 +baz=bazvalue +url = http://192.168.1.1:8080 +[section:sub] +subby=bar + #another comment + ; yet another comment +EOS + ) + end + + it "should do nothing for a setting that does not exist" do + resource = Puppet::Type::Ini_setting.new(common_params.merge( + :section => 'section:sub', :setting => 'foo', :ensure => 'absent')) + provider = described_class.new(resource) + provider.exists?.should be_nil + provider.destroy + validate_file(<<-EOS +[section1] +; This is also a comment +foo=foovalue + +bar = barvalue +master = true +[section2] + +foo= foovalue2 +baz=bazvalue +url = http://192.168.1.1:8080 +[section:sub] +subby=bar + #another comment + ; yet another comment + EOS + ) + end end end |