view modules/concat/spec/acceptance/newline_spec.rb @ 454:d0e7979c7e8c

Update PHP configs for Ubuntu Mostly fixing some INI naming so that it is consistent between packages and what we write (so we don't end up with mixed/duplicate content)
author IBBoard <dev@ibboard.co.uk>
date Sun, 13 Aug 2023 15:26:37 +0100
parents d9352a684e62
children
line wrap: on
line source

require 'spec_helper_acceptance'

describe 'concat ensure_newline parameter' do
  before(:all) do
    @basedir = setup_test_directory
  end
  describe 'when false' do
    let(:pp) do
      <<-MANIFEST
      concat { '#{@basedir}/file':
        ensure_newline => false,
      }
      concat::fragment { '1':
        target  => '#{@basedir}/file',
        content => '1',
      }
      concat::fragment { '2':
        target  => '#{@basedir}/file',
        content => '2',
      }
    MANIFEST
    end

    it 'applies the manifest twice with no stderr' do
      idempotent_apply(pp)
      expect(file("#{@basedir}/file")).to be_file
      expect(file("#{@basedir}/file").content).to match '12'
    end
  end

  describe 'when true' do
    let(:pp) do
      <<-MANIFEST
      concat { '#{@basedir}/file':
        ensure_newline => true,
      }
      concat::fragment { '1':
        target  => '#{@basedir}/file',
        content => '1',
      }
      concat::fragment { '2':
        target  => '#{@basedir}/file',
        content => '2',
      }
    MANIFEST
    end

    it 'applies the manifest twice with no stderr' do
      idempotent_apply(pp)
      expect(file("#{@basedir}/file")).to be_file
      expect(file("#{@basedir}/file").content).to match %r{1\r?\n2\r?\n}
    end
  end
end