OSDN Git Service

Add specs for a couple more Repository methods used by discover_default_branch
authorRobert Speicher <rspeicher@gmail.com>
Wed, 5 Sep 2012 05:02:30 +0000 (01:02 -0400)
committerRobert Speicher <rspeicher@gmail.com>
Wed, 5 Sep 2012 05:02:30 +0000 (01:02 -0400)
spec/roles/repository_spec.rb

index 579425d..0fda57a 100644 (file)
@@ -45,4 +45,28 @@ describe Project, "Repository" do
       project.discover_default_branch.should be_nil
     end
   end
+
+  describe "#root_ref" do
+    it "returns default_branch when set" do
+      project.default_branch = 'stable'
+      project.root_ref.should == 'stable'
+    end
+
+    it "returns 'master' when default_branch is nil" do
+      project.default_branch = nil
+      project.root_ref.should == 'master'
+    end
+  end
+
+  describe "#root_ref?" do
+    it "returns true when branch is root_ref" do
+      project.default_branch = 'stable'
+      project.root_ref?('stable').should be_true
+    end
+
+    it "returns false when branch is not root_ref" do
+      project.default_branch = nil
+      project.root_ref?('stable').should be_false
+    end
+  end
 end