blob: 688c878787eb0029e85d8fd3fede59276856137c (
plain)
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
|
require_relative 'spec_helper'
require_relative '../lib/gitlab_projects'
describe GitlabProjects do
describe :initialize do
before do
argv('add-project', 'gitlab-ci.git')
@gl_projects = GitlabProjects.new
end
it { @gl_projects.project_name.should == 'gitlab-ci.git' }
it { @gl_projects.instance_variable_get(:@command).should == 'add-project' }
it { @gl_projects.instance_variable_get(:@full_path).should == '/home/git/repositories/gitlab-ci.git' }
end
describe :add_project do
before do
argv('add-project', 'gitlab-ci.git')
@gl_projects = GitlabProjects.new
@gl_projects.stub(full_path: tmp_repo_path)
end
after do
FileUtils.rm_rf(tmp_repo_path)
end
it "should create a directory" do
@gl_projects.stub(system: true)
@gl_projects.send :add_project
File.exists?(tmp_repo_path).should be_true
end
it "should receive valid cmd" do
valid_cmd = "cd #{tmp_repo_path} && git init --bare && ln -s #{ROOT_PATH}/hooks/post-receive #{tmp_repo_path}/hooks/post-receive"
@gl_projects.should_receive(:system).with(valid_cmd)
@gl_projects.send :add_project
end
end
def argv(*args)
args.each_with_index do |arg, i|
ARGV[i] = arg
end
end
def tmp_repo_path
File.join(ROOT_PATH, 'tmp', 'gitlab-ci.git')
end
end
|