<commit_before>require 'spec_helper_acceptance'

describe 'replacement of' do
  basedir = default.tmpdir('concat')
  context 'file' do
    context 'should not succeed' do
      before(:all) do
        shell("mkdir -p #{basedir}")
        shell('echo "file exists" > #{basedir}/file')
      end
      after(:all) do
        shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat")
      end

      pp = <<-EOS
        include concat::setup
        concat { '#{basedir}/file':
          replace => false,
        }

        concat::fragment { '1':
          target  => '#{basedir}/file',
          content => '1',
        }

        concat::fragment { '2':
          target  => '#{basedir}/file',
          content => '2',
        }
      EOS

      it 'applies the manifest twice with no stderr' do
        expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
        expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
      end

      describe file("#{basedir}/file") do
        it { should be_file }
        it { should contain 'file exists' }
        it { should_not contain '1' }
        it { should_not contain '2' }
      end
    end

    context 'should succeed' do
      before(:all) do
        shell("mkdir -p #{basedir}")
        shell("echo "file exists" > #{basedir}/file")
      end
      after(:all) do
        shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat")
      end

      pp = <<-EOS
        include concat::setup
        concat { '#{basedir}/file':
          replace => true,<commit_msg>Correct the incorrect quotes<commit_after>require 'spec_helper_acceptance'

describe 'replacement of' do
  basedir = default.tmpdir('concat')
  context 'file' do
    context 'should not succeed' do
      before(:all) do
        shell("mkdir -p #{basedir}")
        shell("echo 'file exists' > #{basedir}/file")
      end
      after(:all) do
        shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat")
      end

      pp = <<-EOS
        include concat::setup
        concat { '#{basedir}/file':
          replace => false,
        }

        concat::fragment { '1':
          target  => '#{basedir}/file',
          content => '1',
        }

        concat::fragment { '2':
          target  => '#{basedir}/file',
          content => '2',
        }
      EOS

      it 'applies the manifest twice with no stderr' do
        expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
        expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
      end

      describe file("#{basedir}/file") do
        it { should be_file }
        it { should contain 'file exists' }
        it { should_not contain '1' }
        it { should_not contain '2' }
      end
    end

    context 'should succeed' do
      before(:all) do
        shell("mkdir -p #{basedir}")
        shell("echo 'file exists' > #{basedir}/file")
      end
      after(:all) do
        shell("rm -rf #{basedir} #{default.puppet['vardir']}/concat")
      end

      pp = <<-EOS
        include concat::setup
        concat { '#{basedir}/file':
          replace => true,
{'fraction_non_alphanumeric': 0.14829018855864493, 'fraction_numerical': 0.003835091083413231, 'mean_word_length': 2.0270793036750483, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6864707', 'n_tokens_mistral': 965, 'n_tokens_neox': 935, 'n_words': 246}