<commit_before>require_relative 'spec_helper'

describe 'osl-php::packages' do
  [CENTOS_7_OPTS, CENTOS_6_OPTS].each do |pltfrm|
    context "on #{pltfrm[:platform]} #{pltfrm[:version]}" do
      context 'using packages with non-versioned prefixes' do
        cached(:chef_run) do
          ChefSpec::SoloRunner.new(pltfrm) do |node|
            node.set['osl-php']['php_packages'] = %w(devel cli)
          end.converge(described_recipe)
        end
        it 'converges successfully' do
          expect { chef_run }.to_not raise_error
        end
        it do
          expect(chef_run).to install_package(
            'php-devel, php-cli, php'
          )
        end
        it do
          expect(chef_run).to install_package('php-pear')
        end
      end
      %w(7.1 7.2).each do |version|
        prefix = "php#{version.split('.').join}u"
        context "using php #{version}" do
          context 'using packages with versioned prefixes' do
            cached(:chef_run) do
              ChefSpec::SoloRunner.new(pltfrm) do |node|
                node.set['php']['version'] = version
                node.set['osl-php']['use_ius'] = true
                node.set['osl-php']['php_packages'] = %w(devel cli)
              end.converge(described_recipe)
            end
            it 'converges successfully' do
              expect { chef_run }.to_not raise_error
            end
            it do
              expect(chef_run).to install_package(
                "#{prefix}-devel, #{prefix}-cli, #{prefix}"
              )
            end
            it do
              expect(chef_run).to install_package('pear')
            end
          end
          context 'old method for backwards compatability' do
            cached(:chef_run) do
              ChefSpec::SoloRunner.new(pltfrm) do |node|
                node.set['php']['version'] = version
                node.set['osl-php']['use_ius'] = true
                node.set['osl-php']['packages'] =
                  %w(devel cli).map { |p| "#{prefix}-#{p}" }
              end.converge(described_recipe)
            end
            it 'converges successfully' do
              expect { chef_run }.to_not raise_error
            end
            it do
              expect(chef_run).to install_package(
                "#{prefix}-devel, #{prefix}-cli, #{prefix}"
              )
            end
            it do
              expect(chef_run).to install_package('pear')
            end
          end
        end
      end
    end
  end
end<commit_msg>Add test for yum_repo exclude.<commit_after>require_relative 'spec_helper'

describe 'osl-php::packages' do
  [CENTOS_7_OPTS, CENTOS_6_OPTS].each do |pltfrm|
    context "on #{pltfrm[:platform]} #{pltfrm[:version]}" do
      context 'using packages with non-versioned prefixes' do
        cached(:chef_run) do
          ChefSpec::SoloRunner.new(pltfrm) do |node|
            node.set['osl-php']['php_packages'] = %w(devel cli)
          end.converge(described_recipe)
        end
        it 'converges successfully' do
          expect { chef_run }.to_not raise_error
        end
        it do
          expect(chef_run).to install_package(
            'php-devel, php-cli, php'
          )
        end
        it do
          expect(chef_run).to install_package('php-pear')
        end
      end
      %w(7.1 7.2).each do |version|
        prefix = "php#{version.split('.').join}u"
        context "using php #{version}" do
          context 'using packages with versioned prefixes' do
            cached(:chef_run) do
              ChefSpec::SoloRunner.new(pltfrm) do |node|
                node.set['php']['version'] = version
                node.set['osl-php']['use_ius'] = true
                node.set['osl-php']['php_packages'] = %w(devel cli)
              end.converge(described_recipe)
            end
            it 'converges successfully' do
              expect { chef_run }.to_not raise_error
            end
            it do
              expect(chef_run).to install_package(
                "#{prefix}-devel, #{prefix}-cli, #{prefix}"
              )
            end
            it do
              expect(chef_run).to install_package('pear')
            end
            if version == '7.1'
              it do
                expect(chef_run).to create_yum_repository('ius').with(
                  exclude: 'php72*'
                )
              end
            end
          end
          context 'old method for backwards compatability' do
            cached(:chef_run) do
              ChefSpec::SoloRunner.new(pltfrm) do |node|
                node.set['php']['version'] = version
                node.set['osl-php']['use_ius'] = true
                node.set['osl-php']['packages'] =
                  %w(devel cli).map { |p| "#{prefix}-#{p}" }
              end.converge(described_recipe)
            end
            it 'converges successfully' do
              expect { chef_run }.to_not raise_error
            end
            it do
              expect(chef_run).to install_package(
                "#{prefix}-devel, #{prefix}-cli, #{prefix}"
              )
            end
            it do
              expect(chef_run).to install_package('pear')
            end
            if version == '7.1'
              it do
                expect(chef_run).to create_yum_repository('ius').with(
                  exclude: 'php72*'
                )
              end
            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11208310552214325, 'fraction_numerical': 0.003644979041370512, 'mean_word_length': 1.5036496350364963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5071882', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1595, 'n_words': 345}