summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/ini_setting
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/puppet/provider/ini_setting')
-rw-r--r--spec/unit/puppet/provider/ini_setting/ruby_spec.rb80
1 files changed, 80 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 19db4c7..4f8bdc1 100644
--- a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb
+++ b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb
@@ -731,4 +731,84 @@ subby=bar
end
+
+ context "when dealing settings that have a commented version present" do
+ let(:orig_content) {
+ <<-EOS
+ [section1]
+ # foo=foovalue
+ bar=barvalue
+ foo = foovalue2
+
+[section2]
+# foo = foovalue
+;bar=barvalue
+blah = blah
+ EOS
+ }
+
+ it "should add a new setting below a commented version of that setting" do
+ resource = Puppet::Type::Ini_setting.new(
+ common_params.merge(:section => 'section2', :setting => 'foo', :value => 'foo3'))
+ provider = described_class.new(resource)
+ provider.exists?.should be_false
+ provider.create
+ validate_file(<<-EOS
+ [section1]
+ # foo=foovalue
+ bar=barvalue
+ foo = foovalue2
+
+[section2]
+# foo = foovalue
+foo = foo3
+;bar=barvalue
+blah = blah
+ EOS
+ )
+ end
+
+ it "should update an existing setting in place, even if there is a commented version of that setting" do
+ resource = Puppet::Type::Ini_setting.new(
+ common_params.merge(:section => 'section1', :setting => 'foo', :value => 'foo3'))
+ provider = described_class.new(resource)
+ provider.exists?.should be_true
+ provider.create
+ validate_file(<<-EOS
+ [section1]
+ # foo=foovalue
+ bar=barvalue
+ foo = foo3
+
+[section2]
+# foo = foovalue
+;bar=barvalue
+blah = blah
+ EOS
+ )
+ end
+
+ it "should add a new setting below a commented version of that setting, respecting semicolons as comments" do
+ resource = Puppet::Type::Ini_setting.new(
+ common_params.merge(:section => 'section2', :setting => 'bar', :value => 'bar3'))
+ provider = described_class.new(resource)
+ provider.exists?.should be_false
+ provider.create
+ validate_file(<<-EOS
+ [section1]
+ # foo=foovalue
+ bar=barvalue
+ foo = foovalue2
+
+[section2]
+# foo = foovalue
+;bar=barvalue
+bar=bar3
+blah = blah
+ EOS
+ )
+ end
+
+ end
+
end