]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb
upgrade to concat 2.0.0
[dsa-puppet.git] / modules / stdlib / spec / unit / puppet / provider / file_line / ruby_spec.rb
1 require 'puppet'
2 require 'tempfile'
3 provider_class = Puppet::Type.type(:file_line).provider(:ruby)
4 describe provider_class do
5   before :each do
6     tmp = Tempfile.new('tmp')
7     @tmpfile = tmp.path
8     tmp.close!
9     @resource = Puppet::Type::File_line.new(
10       {:name => 'foo', :path => @tmpfile, :line => 'foo'}
11     )
12     @provider = provider_class.new(@resource)
13   end
14   it 'should detect if the line exists in the file' do
15     File.open(@tmpfile, 'w') do |fh|
16       fh.write('foo')
17     end
18     @provider.exists?.should be_true
19   end
20   it 'should detect if the line does not exist in the file' do
21     File.open(@tmpfile, 'w') do |fh|
22       fh.write('foo1')
23     end
24     @provider.exists?.should be_nil
25   end
26   it 'should append to an existing file when creating' do
27     @provider.create
28     File.read(@tmpfile).chomp.should == 'foo'
29   end
30 end