summaryrefslogtreecommitdiff
path: root/spec/unit/provider/git_spec.rb
diff options
context:
space:
mode:
authorPawel Kozlowski <pawel.kozlowski@u2i.com>2013-06-17 23:31:02 +0200
committerBryan McLellan <btm@opscode.com>2013-06-18 11:09:13 -0700
commit309635b8b05f620704627be421eef508a735f68b (patch)
treec0d960fda0dd409493c5dbaf46c059743ab9ff71 /spec/unit/provider/git_spec.rb
parenta6b85925db688b174d7a5b9876aff42841226875 (diff)
downloadchef-309635b8b05f620704627be421eef508a735f68b.tar.gz
[CHEF-955] Refactored remote url update conditions
Diffstat (limited to 'spec/unit/provider/git_spec.rb')
-rw-r--r--spec/unit/provider/git_spec.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 608c04becd..763de240cc 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -486,4 +486,53 @@ SHAS
@provider.add_remotes
end
end
+
+ describe "calling multiple_remotes?" do
+ before(:each) do
+ @command_response = double('shell_out')
+ end
+
+ describe "when check remote command returns with status 2" do
+ it "returns true" do
+ @command_response.stub(:exitstatus) { 2 }
+ @provider.multiple_remotes?(@command_response).should be_true
+ end
+ end
+
+ describe "when check remote command returns with status 0" do
+ it "returns false" do
+ @command_response.stub(:exitstatus) { 0 }
+ @provider.multiple_remotes?(@command_response).should be_false
+ end
+ end
+
+ describe "when check remote command returns with status 0" do
+ it "returns false" do
+ @command_response.stub(:exitstatus) { 1 }
+ @provider.multiple_remotes?(@command_response).should be_false
+ end
+ end
+ end
+
+ describe "calling remote_matches?" do
+ before(:each) do
+ @command_response = double('shell_out')
+ end
+
+ describe "when output of the check remote command matches the repository url" do
+ it "returns true" do
+ @command_response.stub(:exitstatus) { 0 }
+ @command_response.stub(:stdout) { @resource.repository }
+ @provider.remote_matches?(@resource.repository, @command_response).should be_true
+ end
+ end
+
+ describe "when output of the check remote command doesn't match the repository url" do
+ it "returns false" do
+ @command_response.stub(:exitstatus) { 0 }
+ @command_response.stub(:stdout) { @resource.repository + "test" }
+ @provider.remote_matches?(@resource.repository, @command_response).should be_false
+ end
+ end
+ end
end