Sha256: 0bccdeb7eaf87c2ebb502b1186fd1a28f6bf8c20403e6f878c3572b0576d4542

Contents?: true

Size: 1.46 KB

Versions: 19

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe EY::Repo do
  before(:each) do
    @path = Pathname.new("/tmp/ey-test/.git/")
    @path.mkpath
    @r = EY::Repo.new("/tmp/ey-test")
  end

  after(:each) do
    clear_urls
  end

  def set_head(head)
    @path.join("HEAD").open('w') {|f| f.write(head) }
  end

  def config_path
    @path.join("config")
  end

  def set_url(url, remote)
    system("mkdir -p #{@path} && cd #{@path} && git init -q")
    system("git config -f #{config_path} remote.#{remote}.url #{url}")
  end

  def clear_urls
    system("rm -rf #{config_path}")
  end

  describe "current_branch method" do
    it "returns the name of the current branch" do
      set_head "ref: refs/heads/master"
      @r.current_branch.should == "master"
    end

    it "returns nil if there is no current branch" do
      set_head "20bf478ab6a91ec5771130aa4c8cfd3d150c4146"
      @r.current_branch.should be_nil
    end
  end # current_branch

  describe "#fail_on_no_remotes!" do
    it "raises when there are no remotes" do
      lambda { @r.fail_on_no_remotes! }.should raise_error(EY::NoRemotesError)
    end
  end

  describe "#has_remote?" do
    it "returns the urls of the remotes" do
      origin_url = "git://github.com/engineyard/engineyard.git"
      other_url = "git@github.com:engineyard/engineyard.git"
      set_url origin_url, "origin"
      set_url other_url,  "other"
      @r.should have_remote(origin_url)
      @r.should have_remote(other_url)
    end
  end # url

end # EY::Repo

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
engineyard-1.4.29 spec/engineyard/repo_spec.rb
engineyard-1.4.28 spec/engineyard/repo_spec.rb
engineyard-1.4.27 spec/engineyard/repo_spec.rb
engineyard-1.4.24 spec/engineyard/repo_spec.rb
engineyard-1.4.23 spec/engineyard/repo_spec.rb
engineyard-1.4.22 spec/engineyard/repo_spec.rb
engineyard-1.4.21 spec/engineyard/repo_spec.rb
engineyard-1.4.20 spec/engineyard/repo_spec.rb
engineyard-1.4.19 spec/engineyard/repo_spec.rb
engineyard-1.4.18 spec/engineyard/repo_spec.rb
engineyard-1.4.17 spec/engineyard/repo_spec.rb
engineyard-1.4.16 spec/engineyard/repo_spec.rb
engineyard-1.4.15 spec/engineyard/repo_spec.rb
engineyard-1.4.14 spec/engineyard/repo_spec.rb
engineyard-1.4.13 spec/engineyard/repo_spec.rb
engineyard-1.4.11 spec/engineyard/repo_spec.rb
engineyard-1.4.10 spec/engineyard/repo_spec.rb
engineyard-1.4.9 spec/engineyard/repo_spec.rb
engineyard-1.4.8 spec/engineyard/repo_spec.rb