newline_spec.rb 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. require 'spec_helper_acceptance'
  2. describe 'concat ensure_newline parameter' do
  3. basedir = default.tmpdir('concat')
  4. context '=> false' do
  5. before(:all) do
  6. pp = <<-EOS
  7. file { '#{basedir}':
  8. ensure => directory
  9. }
  10. EOS
  11. apply_manifest(pp)
  12. end
  13. pp = <<-EOS
  14. concat { '#{basedir}/file':
  15. ensure_newline => false,
  16. }
  17. concat::fragment { '1':
  18. target => '#{basedir}/file',
  19. content => '1',
  20. }
  21. concat::fragment { '2':
  22. target => '#{basedir}/file',
  23. content => '2',
  24. }
  25. EOS
  26. it 'applies the manifest twice with no stderr' do
  27. apply_manifest(pp, :catch_failures => true)
  28. apply_manifest(pp, :catch_changes => true)
  29. end
  30. describe file("#{basedir}/file") do
  31. it { should be_file }
  32. it { should contain '12' }
  33. end
  34. end
  35. context '=> true' do
  36. pp = <<-EOS
  37. concat { '#{basedir}/file':
  38. ensure_newline => true,
  39. }
  40. concat::fragment { '1':
  41. target => '#{basedir}/file',
  42. content => '1',
  43. }
  44. concat::fragment { '2':
  45. target => '#{basedir}/file',
  46. content => '2',
  47. }
  48. EOS
  49. it 'applies the manifest twice with no stderr' do
  50. apply_manifest(pp, :catch_failures => true)
  51. apply_manifest(pp, :catch_changes => true)
  52. end
  53. describe file("#{basedir}/file") do
  54. it { should be_file }
  55. it("should contain 1\n2\n", :unless => (fact('osfamily') == 'Solaris')) {
  56. should contain "1\n2\n"
  57. }
  58. end
  59. end
  60. end