summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Bode <dan@puppetlabs.com>2012-10-02 18:53:53 -0700
committerDan Bode <dan@puppetlabs.com>2012-10-02 18:53:53 -0700
commitcbc90d38347f8ca61de2208b16ffc76f9fd5938c (patch)
treee000b4755f7157439d48aaeab0fe081685ae0e59 /spec
parent1564c473a93105399bd777e78090463156948f2e (diff)
downloadpuppet-inifile-cbc90d38347f8ca61de2208b16ffc76f9fd5938c.tar.gz
puppet-inifile-cbc90d38347f8ca61de2208b16ffc76f9fd5938c.tar.bz2
Make value a property
This commit converts value to a property so that it can be managed and modified when a file already has a value set. It was previously treating the line creation state the same as the update case, which is not in alignment with Puppet's model.
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/puppet/provider/ini_setting/ruby_spec.rb57
1 files changed, 31 insertions, 26 deletions
diff --git a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb
index 20882fd..4062205 100644
--- a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb
+++ b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb
@@ -54,7 +54,7 @@ subby=bar
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:setting => 'yahoo', :value => 'yippee'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
# This is a comment
@@ -82,7 +82,7 @@ subby=bar
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section:sub', :setting => 'yahoo', :value => 'yippee'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
# This is a comment
@@ -110,8 +110,8 @@ yahoo = yippee
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:setting => 'baz', :value => 'bazvalue2'))
provider = described_class.new(resource)
- provider.exists?.should == false
- provider.create
+ provider.exists?.should == 'bazvalue'
+ provider.value=('bazvalue2')
validate_file(<<-EOS
# This is a comment
[section1]
@@ -137,8 +137,9 @@ subby=bar
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section:sub', :setting => 'subby', :value => 'foo'))
provider = described_class.new(resource)
- provider.exists?.should == false
- provider.create
+ provider.exists?.should == 'bar'
+ provider.value.should == 'bar'
+ provider.value=('foo')
validate_file(<<-EOS
# This is a comment
[section1]
@@ -164,8 +165,9 @@ subby = foo
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:setting => 'url', :value => 'http://192.168.0.1:8080'))
provider = described_class.new(resource)
- provider.exists?.should == false
- provider.create
+ provider.exists?.should == 'http://192.168.1.1:8080'
+ provider.value.should == 'http://192.168.1.1:8080'
+ provider.value=('http://192.168.0.1:8080')
validate_file( <<-EOS
# This is a comment
@@ -192,14 +194,14 @@ subby=bar
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:setting => 'baz', :value => 'bazvalue'))
provider = described_class.new(resource)
- provider.exists?.should == true
+ provider.exists?.should == 'bazvalue'
end
it "should add a new section if the section does not exist" do
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => "section3", :setting => 'huzzah', :value => 'shazaam'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
# This is a comment
@@ -229,7 +231,7 @@ huzzah = shazaam
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => "section:subsection", :setting => 'huzzah', :value => 'shazaam'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
# This is a comment
@@ -259,7 +261,7 @@ huzzah = shazaam
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => "section1", :setting => 'setting1', :value => 'hellowworld', :path => emptyfile))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file("
[section1]
@@ -271,7 +273,7 @@ setting1 = hellowworld
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => "section:subsection", :setting => 'setting1', :value => 'hellowworld', :path => emptyfile))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file("
[section:subsection]
@@ -283,8 +285,8 @@ setting1 = hellowworld
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => "section1", :setting => 'master', :value => true))
provider = described_class.new(resource)
- provider.exists?.should == true
- provider.create
+ provider.exists?.should == 'true'
+ provider.value.should == 'true'
end
end
@@ -305,7 +307,7 @@ foo = http://192.168.1.1:8080
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => '', :setting => 'bar', :value => 'yippee'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
# This is a comment
@@ -322,8 +324,9 @@ foo = http://192.168.1.1:8080
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => '', :setting => 'foo', :value => 'yippee'))
provider = described_class.new(resource)
- provider.exists?.should == false
- provider.create
+ provider.exists?.should == 'blah'
+ provider.value.should == 'blah'
+ provider.value=('yippee')
validate_file(<<-EOS
# This is a comment
foo = yippee
@@ -338,7 +341,7 @@ foo = http://192.168.1.1:8080
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => '', :setting => 'foo', :value => 'blah'))
provider = described_class.new(resource)
- provider.exists?.should == true
+ provider.exists?.should == 'blah'
end
end
@@ -354,7 +357,7 @@ foo = http://192.168.1.1:8080
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => '', :setting => 'foo', :value => 'yippee'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
foo = yippee
@@ -368,8 +371,9 @@ foo = http://192.168.1.1:8080
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section2', :setting => 'foo', :value => 'yippee'))
provider = described_class.new(resource)
- provider.exists?.should == false
- provider.create
+ provider.exists?.should == 'http://192.168.1.1:8080'
+ provider.value.should == 'http://192.168.1.1:8080'
+ provider.value=('yippee')
validate_file(<<-EOS
[section2]
foo = yippee
@@ -381,7 +385,7 @@ foo = yippee
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section2', :setting => 'bar', :value => 'baz'))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
[section2]
@@ -427,8 +431,9 @@ foo=bar
:value => 'yippee',
:key_val_separator => '='))
provider = described_class.new(resource)
- provider.exists?.should == false
- provider.create
+ provider.exists?.should == 'bar'
+ provider.value.should == 'bar'
+ provider.value=('yippee')
validate_file(<<-EOS
[section2]
foo=yippee
@@ -443,7 +448,7 @@ foo=yippee
:value => 'baz',
:key_val_separator => '='))
provider = described_class.new(resource)
- provider.exists?.should == false
+ provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
[section2]