<commit_before>require 'spec_helper'

describe "gitlab::git" do
  let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::git") }


  describe "under ubuntu" do
    ["12.04", "10.04"].each do |version|
      let(:chef_run) do 
        runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
        runner.node.set['gitlab']['env'] = "production"
        runner.converge("gitlab::git")
      end

      before do
        stub_command("test -f /var/chef/cache/git-1.8.4.1.zip").and_return(false)
        stub_command("git --version | grep 1.8.4.1").and_return(false)
      end

      it "installs all git required packages" do
        packages = %w{unzip build-essential libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev}
        packages.each do |pkg|
          expect(chef_run).to install_package(pkg)
        end
      end

      it 'gets the source code for git' do
        expect(chef_run).to create_remote_file('/var/chef/cache/git-1.8.4.1.zip').with(mode: 0644, source: "https://github.com/git/git/archive/v1.8.4.1.zip")
      end

      it 'executes compiling git from source' do
        resource = chef_run.find_resource(:execute, 'Extracting and Building Git 1.8.4.1 from Source')
        expect(resource.command).to eq("    unzip -q git-1.8.4.1.zip\n    cd git-1.8.4.1 && make prefix=/usr/local install\n")
        expect(resource.cwd).to eq("/var/chef/cache")
      end
    end
  end

    describe "under centos" do
    ["5.8", "6.4"].each do |version|
      let(:chef_run) do 
        runner = ChefSpec::Runner.new(platform: "centos", version: version)
        runner.node.set['gitlab']['env'] = "production"
        runner.converge("gitlab::git")
      end

      before do
        stub_command("test -f /var/chef/cache/git-1.8.4.1.zip").and_return(false)
        stub_command("git --version | grep 1.8.4.1").and_return(false)
      end

      it "installs all git required packages" do
        packages = %w{expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel}
        packages.each do |pkg|
          expect(chef_run).to install_package(pkg)
        end
      end

      it 'gets the source code for git' do
        expect(chef_run).to create_remote_file('/var/chef/cache/git-1.8.4.1.zip').with(mode: 0644, source: "https://github.com/git/git/archive/v1.8.4.1.zip")
      end

      it 'executes compiling git from source' do
        resource = chef_run.find_resource(:execute, 'Extracting and Building Git 1.8.4.1 from Source')
        expect(resource.command).to eq("    unzip -q git-1.8.4.1.zip\n    cd git-1.8.4.1 && make prefix=/usr/local install\n")
        expect(resource.cwd).to eq("/var/chef/cache")
      end
    end
  end
end<commit_msg> Merge branch 'fix-git-spec' into 'master'<commit_after>require 'spec_helper'

describe "gitlab::git" do
  let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::git") }


  describe "under ubuntu" do
    ["12.04", "10.04"].each do |version|
      let(:chef_run) do
        runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
        runner.node.set['gitlab']['env'] = "production"
        runner.converge("gitlab::git")
      end

      before do
        stub_command("test -f #{Chef::Config['file_cache_path']}/git-1.8.4.1.zip").and_return(false)
        stub_command("git --version | grep 1.8.4.1").and_return(false)
      end

      it "installs all git required packages" do
        packages = %w{unzip build-essential libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev}
        packages.each do |pkg|
          expect(chef_run).to install_package(pkg)
        end
      end

      it 'gets the source code for git' do
        expect(chef_run).to create_remote_file("#{Chef::Config['file_cache_path']}/git-1.8.4.1.zip").with(mode: 0644, source: "https://github.com/git/git/archive/v1.8.4.1.zip")
      end

      it 'executes compiling git from source' do
        resource = chef_run.find_resource(:execute, 'Extracting and Building Git 1.8.4.1 from Source')
        expect(resource.command).to eq("    unzip -q git-1.8.4.1.zip\n    cd git-1.8.4.1 && make prefix=/usr/local install\n")
        expect(resource.cwd).to eq(Chef::Config['file_cache_path'])
      end
    end
  end

    describe "under centos" do
    ["5.8", "6.4"].each do |version|
      let(:chef_run) do
        runner = ChefSpec::Runner.new(platform: "centos", version: version)
        runner.node.set['gitlab']['env'] = "production"
        runner.converge("gitlab::git")
      end

      before do
        stub_command("test -f #{Chef::Config['file_cache_path']}/git-1.8.4.1.zip").and_return(false)
        stub_command("git --version | grep 1.8.4.1").and_return(false)
      end

      it "installs all git required packages" do
        packages = %w{expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel}
        packages.each do |pkg|
          expect(chef_run).to install_package(pkg)
        end
      end

      it 'gets the source code for git' do
        expect(chef_run).to create_remote_file("#{Chef::Config['file_cache_path']}/git-1.8.4.1.zip").with(mode: 0644, source: "https://github.com/git/git/archive/v1.8.4.1.zip")
      end

      it 'executes compiling git from source' do
        resource = chef_run.find_resource(:execute, 'Extracting and Building Git 1.8.4.1 from Source')
        expect(resource.command).to eq("    unzip -q git-1.8.4.1.zip\n    cd git-1.8.4.1 && make prefix=/usr/local install\n")
        expect(resource.cwd).to eq(Chef::Config['file_cache_path'])
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.14728543271815087, 'fraction_numerical': 0.027951979931911845, 'mean_word_length': 2.7065073041168657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 28, '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': '2080512', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1919, 'n_words': 402}