diff options
author | Chris Price <chris@puppetlabs.com> | 2012-09-20 12:53:59 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2012-09-20 12:53:59 -0700 |
commit | 4ff4995d9efa15504eaf33e27385b5e2c4092087 (patch) | |
tree | 363d5bd285f3f03e113b08b1deae5eac45eb98da /spec | |
parent | 310a4b1575f7af903ac97108c6f1352d05f5f3fc (diff) | |
parent | e527908b7c6ac5d91677229a96d5a97194dc68b7 (diff) | |
download | puppet-inifile-4ff4995d9efa15504eaf33e27385b5e2c4092087.tar.gz puppet-inifile-4ff4995d9efa15504eaf33e27385b5e2c4092087.tar.bz2 |
Merge pull request #9 from cprice-puppet/feature/master/allow-override-of-separator-str
Allow overriding separator string between key/val pairs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/puppet/provider/ini_setting/ruby_spec.rb | 64 |
1 files changed, 64 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 2dbbf55..20882fd 100644 --- a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb +++ b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb @@ -392,4 +392,68 @@ bar = baz end end + context "when overriding the separator" do + let(:orig_content) { + <<-EOS +[section2] +foo=bar + EOS + } + + it "should fail if the separator doesn't include an equals sign" do + expect { + Puppet::Type::Ini_setting.new(common_params.merge( + :section => 'section2', + :setting => 'foo', + :value => 'yippee', + :key_val_separator => '+')) + }.to raise_error Puppet::Error, /must contain exactly one/ + end + + it "should fail if the separator includes more than one equals sign" do + expect { + Puppet::Type::Ini_setting.new(common_params.merge( + :section => 'section2', + :setting => 'foo', + :value => 'yippee', + :key_val_separator => ' = foo = ')) + }.to raise_error Puppet::Error, /must contain exactly one/ + end + + it "should modify an existing setting" do + resource = Puppet::Type::Ini_setting.new(common_params.merge( + :section => 'section2', + :setting => 'foo', + :value => 'yippee', + :key_val_separator => '=')) + provider = described_class.new(resource) + provider.exists?.should == false + provider.create + validate_file(<<-EOS +[section2] +foo=yippee + EOS + ) + end + + it "should add a new setting" do + resource = Puppet::Type::Ini_setting.new(common_params.merge( + :section => 'section2', + :setting => 'bar', + :value => 'baz', + :key_val_separator => '=')) + provider = described_class.new(resource) + provider.exists?.should == false + provider.create + validate_file(<<-EOS +[section2] +foo=bar +bar=baz + EOS + ) + end + + + end + end |