diff options
author | Adrien Thebo <git@somethingsinistral.net> | 2013-07-11 16:26:45 -0700 |
---|---|---|
committer | Adrien Thebo <git@somethingsinistral.net> | 2013-07-11 16:26:45 -0700 |
commit | e0d4588bd2470109bd1eea4e597f1d205bf01b52 (patch) | |
tree | 07e1aae2e2028fd0b0d50f999a5cab3ddf02704c /spec/unit/puppet | |
parent | 4d2558f383e18bbe322dd0feb073555491216ab4 (diff) | |
parent | 964a9ad6193b0dd243a44ddae1509655fc9e9fb8 (diff) | |
download | puppet-stdlib-e0d4588bd2470109bd1eea4e597f1d205bf01b52.tar.gz puppet-stdlib-e0d4588bd2470109bd1eea4e597f1d205bf01b52.tar.bz2 |
Merge branch 'pull-163'
This closes GH-163
Diffstat (limited to 'spec/unit/puppet')
-rw-r--r-- | spec/unit/puppet/provider/file_line/ruby_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index 7857d39..648c05b 100644 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -61,6 +61,39 @@ describe provider_class do File.read(@tmpfile).should eql("foo1\nfoo=blah\nfoo2\nfoo=baz") end + it 'should replace all lines that matches' do + @resource = Puppet::Type::File_line.new( + { + :name => 'foo', + :path => @tmpfile, + :line => 'foo = bar', + :match => '^foo\s*=.*$', + :multiple => true + } + ) + @provider = provider_class.new(@resource) + File.open(@tmpfile, 'w') do |fh| + fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") + end + @provider.exists?.should be_nil + @provider.create + File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2\nfoo = bar") + end + + it 'should raise an error with invalid values' do + expect { + @resource = Puppet::Type::File_line.new( + { + :name => 'foo', + :path => @tmpfile, + :line => 'foo = bar', + :match => '^foo\s*=.*$', + :multiple => 'asgadga' + } + ) + }.to raise_error(Puppet::Error, /Invalid value "asgadga"\. Valid values are true, false\./) + end + it 'should replace a line that matches' do File.open(@tmpfile, 'w') do |fh| fh.write("foo1\nfoo=blah\nfoo2") |