diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-03-07 17:06:54 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-03-07 17:06:54 +0100 |
commit | e71fcd9eec529b40e87965924a1b87ab7bb86528 (patch) | |
tree | 817d0d3e8410b8e0580e7500c8dc94cab7992883 /spec/gitlab_projects_spec.rb | |
parent | 4e22874b691e229d6f151c636b03a7ab5c3f2f7c (diff) | |
download | gitlab-shell-e71fcd9eec529b40e87965924a1b87ab7bb86528.tar.gz |
Use IO.popen instead of Kernel#` to read refs
Diffstat (limited to 'spec/gitlab_projects_spec.rb')
-rw-r--r-- | spec/gitlab_projects_spec.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index 4341ca5..306597e 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -31,8 +31,8 @@ describe GitlabProjects do it "should create a branch" do gl_projects_create.exec gl_projects.exec - branch_ref = `cd #{tmp_repo_path} && git rev-parse test_branch`.strip - master_ref = `cd #{tmp_repo_path} && git rev-parse master`.strip + branch_ref = capture_in_tmp_repo(%W(git rev-parse test_branch)) + master_ref = capture_in_tmp_repo(%W(git rev-parse master)) branch_ref.should == master_ref end end @@ -49,9 +49,9 @@ describe GitlabProjects do it "should remove a branch" do gl_projects_create.exec gl_projects_create_branch.exec - branch_ref = `cd #{tmp_repo_path} && git rev-parse test_branch`.strip + branch_ref = capture_in_tmp_repo(%W(git rev-parse test_branch)) gl_projects.exec - branch_del = `cd #{tmp_repo_path} && git rev-parse test_branch`.strip + branch_del = capture_in_tmp_repo(%W(git rev-parse test_branch)) branch_del.should_not == branch_ref end end @@ -65,8 +65,8 @@ describe GitlabProjects do it "should create a tag" do gl_projects_create.exec gl_projects.exec - tag_ref = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip - master_ref = `cd #{tmp_repo_path} && git rev-parse master`.strip + tag_ref = capture_in_tmp_repo(%W(git rev-parse test_tag)) + master_ref = capture_in_tmp_repo(%W(git rev-parse master)) tag_ref.should == master_ref end end @@ -83,9 +83,9 @@ describe GitlabProjects do it "should remove a branch" do gl_projects_create.exec gl_projects_create_tag.exec - branch_ref = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip + branch_ref = capture_in_tmp_repo(%W(git rev-parse test_tag)) gl_projects.exec - branch_del = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip + branch_del = capture_in_tmp_repo(%W(git rev-parse test_tag)) branch_del.should_not == branch_ref end end @@ -300,4 +300,8 @@ describe GitlabProjects do def repo_name 'gitlab-ci.git' end + + def capture_in_tmp_repo(cmd) + IO.popen(cmd, chdir: tmp_repo_path).read.strip + end end |