Sha256: 3f3f6a401414c7015f5e539c1e6edfff81620f2e1507603f51b07ca2f5d5da5e

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require File.dirname(__FILE__) + '/helper'

describe Mercurial::BranchFactory do
  
  before do
    @repository = Mercurial::Repository.open(Fixtures.test_repo)
  end
  
  it "should find all branches" do
    branches = @repository.branches.all
    branches.size.must_equal 5
    branches.map(&:name).sort.must_equal %w(branch-from-remote another-branch new-branch old-branch default).sort
    branches.map(&:status).sort.must_equal %w(active active closed active active).sort
  end

  it "should iterate through branches" do
    names = []
    @repository.branches.each{|b| names << b.name }
    names.size.must_equal 5
    names.must_equal %w(default another-branch branch-from-remote new-branch old-branch)
  end
  
  it "should find active branches" do
    branches = @repository.branches.active
    branches.size.must_equal 4
    branches.map(&:name).sort.must_equal %w(another-branch new-branch default branch-from-remote).sort
    branches.map(&:status).must_equal %w(active active active active)
  end
  
  it "should find closed branches" do
    branches = @repository.branches.closed
    branches.size.must_equal 1
    branches.map(&:name).must_equal %w(old-branch)
    branches.map(&:status).must_equal %w(closed)
  end
  
  it "should find branch by name" do
    branch = @repository.branches.by_name('new-branch')
    branch.must_be_kind_of(Mercurial::Branch)
    branch.status.must_equal 'active'
  end
  
  it "should not find a branch by inexistent name" do
    @repository.branches.by_name('bla-branch-f').must_equal nil
  end
  
  it "should return branches for commit" do
    branches = @repository.branches.for_commit('bf6386c0a0cc')
    branches.size.must_equal 5
    branches.map(&:name).sort.must_equal %w(old-branch new-branch branch-from-remote another-branch default).sort
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mercurial-ruby-0.7.3 test/test_branch_factory.rb
mercurial-ruby-0.7.2 test/test_branch_factory.rb