diff options
author | varac <varacanero@zeromail.org> | 2013-08-27 18:03:56 +0200 |
---|---|---|
committer | varac <varacanero@zeromail.org> | 2013-08-27 18:03:56 +0200 |
commit | 473896f2ca22f5003ea47542ad8026819d2d8613 (patch) | |
tree | 297936a37a0cf217a76a5cee368f7f91430d9f02 /spec/unit/puppet/provider | |
parent | 966f3b349a60b3997e58af1095bbd96671952fac (diff) | |
parent | 2a78cbfaad2acc61d6d8bab715db00c9890adbd7 (diff) |
Merge branch 'master' of git://github.com/puppetlabs/puppetlabs-stdlib into leap_master
Diffstat (limited to 'spec/unit/puppet/provider')
-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") |