Sha256: ae6100992ca2f47d1b940df9c6143d29a0e13f1a2898ccd188e83daafca7310f

Contents?: true

Size: 1.69 KB

Versions: 10

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

module Berkshelf
  describe Git do
    describe "ClassMethods" do
      subject { Git }

      describe "#find_git" do
        it "should find git" do
          subject.find_git.should_not be_nil
        end

        it "should raise if it can't find git" do
          begin
            path = ENV["PATH"]
            ENV["PATH"] = ""

            lambda { subject.find_git }.should raise_error
          ensure
            ENV["PATH"] = path
          end
        end
      end

      describe "#clone" do
        let(:target) { tmp_path.join("nginx") }

        it "clones the repository to the target path" do
          subject.clone("git://github.com/opscode-cookbooks/nginx.git", target)

          target.should exist
          target.should be_directory
        end
      end

      describe "#checkout" do
        let(:repo_path) { tmp_path.join("nginx") }
        let(:repo) { subject.clone("git://github.com/opscode-cookbooks/nginx.git", repo_path) }
        let(:tag) { "0.101.2" }

        it "checks out the specified path of the given repository" do
          subject.checkout(repo, tag)

          Dir.chdir repo_path do
            %x[git rev-parse #{tag}].should == %x[git rev-parse HEAD]
          end
        end
      end

      describe "#rev_parse" do
        let(:repo_path) { tmp_path.join("nginx") }
        before(:each) do
          subject.clone("git://github.com/opscode-cookbooks/nginx.git", repo_path)
          subject.checkout(repo_path, "0e4887d9eef8cb83972f974a85890983c8204c3b")
        end

        it "returns the ref for HEAD" do
          subject.rev_parse(repo_path).should eql("0e4887d9eef8cb83972f974a85890983c8204c3b")
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
berkshelf-0.3.3 spec/unit/berkshelf/git_spec.rb
berkshelf-0.3.2 spec/unit/berkshelf/git_spec.rb
berkshelf-0.3.1 spec/unit/berkshelf/git_spec.rb
berkshelf-0.3.0 spec/unit/berkshelf/git_spec.rb
berkshelf-0.2.0 spec/unit/berkshelf/git_spec.rb
berkshelf-0.1.5 spec/unit/berkshelf/git_spec.rb
berkshelf-0.1.4 spec/unit/berkshelf/git_spec.rb
berkshelf-0.1.3 spec/unit/berkshelf/git_spec.rb
berkshelf-0.1.2 spec/unit/berkshelf/git_spec.rb
berkshelf-0.1.1 spec/unit/berkshelf/git_spec.rb