File: ticgit_spec.rb

package info (click to toggle)
ticgit 1.0.2.18-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: ruby: 2,848; sh: 124; makefile: 16
file content (54 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require File.dirname(__FILE__) + "/spec_helper"

describe TicGitNG do
  include TicGitNGSpecHelper

  before(:all) do
    @path = setup_new_git_repo
    @orig_test_opts = test_opts
    @ticgitng = TicGitNG.open(@path, @orig_test_opts)
  end

  after(:all) do
    Dir.glob(File.expand_path("~/.ticgit-ng/-tmp*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
    Dir.glob(File.expand_path("~/.ticgit/-tmp*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
    Dir.glob(File.expand_path("/tmp/ticgit-ng-*")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }
  end

  it "Should only create a new branch when 'ti init' is called" do
    git_dir_2=        setup_new_git_repo
    git_opts_2=       test_opts
    git_opts_2[:init]=false

    #With :init set to false, the default when calling ti
    lambda { ticgitng_2=TicGitNG.open(git_dir_2, git_opts_2) }.should raise_error SystemExit

    #with :init set to true, the default for TicGitNGSpecHelper.test_opts(), the branch should be created without error
    lambda { ticgitng=TicGitNG.open( @path, @orig_test_opts )}.should_not raise_error SystemExit

  end

  it "should create a new branch if it's not there" do
    br = @ticgitng.git.branches.map { |b| b.name }
    br.should include('ticgit')
  end

  it "should find an existing ticgit-ng branch if it's there" do
    tg = TicGitNG.open(@path, test_opts)
    @ticgitng.git.branches.size.should eql(tg.git.branches.size)
  end

  it "should find the .git directory if it's there" do
    @ticgitng.git.dir.path.should eql(@path)
  end

  it "should look for the .git directory until it finds it" do
    tg = TicGitNG.open(File.join(@path, 'subdir'), @orig_test_opts)
    tg.git.dir.path.should eql(@path)
  end

  it "should add a .hold file to a new branch" do
    @ticgitng.in_branch{ File.file?('.hold').should == true }
  end

end