summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/provider/file_line/ruby_spec.rb
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-08-08 09:47:30 -0700
committerKen Barber <ken@bob.sh>2011-08-08 09:47:30 -0700
commitef4ef11ae0bad1aa2d7659aa7774df9e39146855 (patch)
tree7a705b349ab1f976328eef1fa7c3e7167a1bd769 /spec/unit/puppet/provider/file_line/ruby_spec.rb
parent07d0eca31780bba76f2283ce83f944473ce8fe00 (diff)
parentf3c53e6f1943417a1690f5a976076f24277c6b06 (diff)
Merge pull request #10 from jeffmccune/ticket/master/8792_rename_whole_line_to_file_line
(#8792) Rename whole_line type to file_line.
Diffstat (limited to 'spec/unit/puppet/provider/file_line/ruby_spec.rb')
-rw-r--r--spec/unit/puppet/provider/file_line/ruby_spec.rb30
1 files changed, 30 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
new file mode 100644
index 0000000..b03fc0e
--- /dev/null
+++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb
@@ -0,0 +1,30 @@
+require 'puppet'
+require 'tempfile'
+provider_class = Puppet::Type.type(:file_line).provider(:ruby)
+describe provider_class do
+ before :each do
+ tmp = Tempfile.new('tmp')
+ @tmpfile = tmp.path
+ tmp.close!
+ @resource = Puppet::Type::File_line.new(
+ {:name => 'foo', :path => @tmpfile, :line => 'foo'}
+ )
+ @provider = provider_class.new(@resource)
+ end
+ it 'should detect if the line exists in the file' do
+ File.open(@tmpfile, 'w') do |fh|
+ fh.write('foo')
+ end
+ @provider.exists?.should be_true
+ end
+ it 'should detect if the line does not exist in the file' do
+ File.open(@tmpfile, 'w') do |fh|
+ fh.write('foo1')
+ end
+ @provider.exists?.should be_nil
+ end
+ it 'should append to an existing file when creating' do
+ @provider.create
+ File.read(@tmpfile).chomp.should == 'foo'
+ end
+end