<commit_before>require 'spec_helper'

describe 'chef-client::init_service' do
  centos6 = { platform: 'centos', version: '6.9', conf_dir: 'sysconfig' }
  ubuntu = { platform: 'ubuntu', version: '14.04', conf_dir: 'init.d' }

  context "#{centos6[:platform]} #{centos6[:version]}" do
    let(:chef_run) do
      ChefSpec::ServerRunner.new(platform: centos6[:platform], version: centos6[:version]) do |node|
        node.normal['chef_client']['daemon_options'] = ['-E client-args']
      end.converge(described_recipe)
    end

    it 'should set -E client-args' do
      expect(chef_run).to render_file("/etc/#{centos6[:conf_dir]}/chef-client") \
        .with_content(/OPTIONS="-E client-args"/)
    end
  end

  context "#{ubuntu[:platform]} #{ubuntu[:version]}" do
    let(:chef_run) do
      ChefSpec::ServerRunner.new(platform: ubuntu[:platform], version: ubuntu[:version]) do |node|
        node.normal['chef_client']['daemon_options'] = ['-E client-args']
      end.converge(described_recipe)
    end

    it 'should set -E client-args' do
      expect(chef_run).to render_file("/etc/#{ubuntu[:conf_dir]}/chef-client") \
        .with_content(/DAEMON_OPTS=".*-E client-args"/)
    end
  end
end<commit_msg>Add some specs for the SLES 11 init file<commit_after>require 'spec_helper'

describe 'chef-client::init_service' do
  centos6 = { platform: 'centos', version: '6.9', conf_dir: 'sysconfig' }
  ubuntu = { platform: 'ubuntu', version: '14.04', conf_dir: 'init.d' }
  sles = { platform: 'suse', version: '11.4', conf_dir: 'init.d' }

  context "#{centos6[:platform]} #{centos6[:version]}" do
    let(:chef_run) do
      ChefSpec::ServerRunner.new(platform: centos6[:platform], version: centos6[:version]) do |node|
        node.normal['chef_client']['daemon_options'] = ['-E client-args']
      end.converge(described_recipe)
    end

    it 'should set -E client-args' do
      expect(chef_run).to render_file("/etc/#{centos6[:conf_dir]}/chef-client") \
        .with_content(/OPTIONS="-E client-args"/)
    end
  end

  context "#{ubuntu[:platform]} #{ubuntu[:version]}" do
    let(:chef_run) do
      ChefSpec::ServerRunner.new(platform: ubuntu[:platform], version: ubuntu[:version]) do |node|
        node.normal['chef_client']['daemon_options'] = ['-E client-args']
      end.converge(described_recipe)
    end

    it 'should set -E client-args' do
      expect(chef_run).to render_file("/etc/#{ubuntu[:conf_dir]}/chef-client") \
        .with_content(/DAEMON_OPTS=".*-E client-args"/)
    end
  end

  context "#{sles[:platform]} #{sles[:version]} without daemon options" do
    cached(:chef_run) do
      ChefSpec::ServerRunner.new(platform: sles[:platform], version: sles[:version]) do |node|
        node.normal['ohai']['daemon_options'] = []
      end.converge(described_recipe)
    end

    it 'should not include OPTIONS in chef-client start command' do
      expect(chef_run).not_to render_file("/etc/#{sles[:conf_dir]}/chef-client") \
        .with_content(%r{"\$OPTIONS"})
    end
  end

  context "#{sles[:platform]} #{sles[:version]} with daemon options" do
    cached(:chef_run) do
      ChefSpec::ServerRunner.new(platform: sles[:platform], version: sles[:version]) do |node|
        node.normal['chef_client']['daemon_options'] = ['-E client-args']
      end.converge(described_recipe)
    end

    it 'should include OPTIONS in chef-client start command' do
      expect(chef_run).to render_file("/etc/#{sles[:conf_dir]}/chef-client") \
        .with_content(%r{"\$OPTIONS"})
    end

    it 'should set PIDFILE to /var/run/chef/client.pid' do
      expect(chef_run).to render_file("/etc/#{sles[:conf_dir]}/chef-client") \
        .with_content(%r{PIDFILE-/var/run/chef/client.pid})
    end
  end
end
{'fraction_non_alphanumeric': 0.17073170731707318, 'fraction_numerical': 0.0077727150897882605, 'mean_word_length': 3.8092783505154637, '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': '6863258', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1282, 'n_words': 248}