examples/presenter_example.rb in cap_gun-0.2.1 vs examples/presenter_example.rb in cap_gun-0.2.2
- old
+ new
@@ -1,42 +1,60 @@
require File.join(File.dirname(__FILE__), *%w[example_helper])
describe CapGun::Presenter do
- describe "git details" do
+ describe "scm details" do
- it "does nothing if git is not the scm" do
- presenter = CapGun::Presenter.new(stub("capistrano", :scm => :svn))
- presenter.git_details.should == nil
+ it "does nothing if the scm is not git nor subversion" do
+ presenter = CapGun::Presenter.new(stub("capistrano", :scm => :mercurial))
+ presenter.scm_details.should == nil
end
it "collects branch and git log details if git is scm" do
capistrano = {:scm => :git, :branch => "edge"}
presenter = CapGun::Presenter.new(capistrano)
- presenter.expects(:git_log).returns("xxxxx")
+ presenter.expects(:scm_log).returns("xxxxx")
- details = presenter.git_details
+ details = presenter.scm_details
details.should include("Branch: edge")
details.should include("xxxxx")
end
end
- describe "git log messages" do
+ describe "scm log messages" do
+ describe "with git" do
+ it "returns N/A if the git log call returns an error" do
+ capistrano = {:scm => :git, :previous_revision => "previous-sha", :current_revision => "current-sha" }
+ presenter = CapGun::Presenter.new(capistrano)
+ presenter.stubs(:`).returns("fatal: Not a git repo")
+ presenter.stubs(:exit_code).returns(stub("process status", :success? => false))
+ presenter.scm_log_messages.should == "N/A"
+ end
- it "returns N/A if the git log call returns an error" do
- capistrano = { :previous_revision => "previous-sha", :current_revision => "current-sha" }
- presenter = CapGun::Presenter.new(capistrano)
- presenter.stubs(:`).returns("fatal: Not a git repo")
- presenter.stubs(:exit_code).returns(stub("process status", :success? => false))
- presenter.git_log_messages.should == "N/A"
+ it "calls git log with previous_rev..current_rev" do
+ capistrano = {:scm => :git, :previous_revision => "previous-sha", :current_revision => "current-sha" }
+ presenter = CapGun::Presenter.new(capistrano)
+ presenter.stubs(:exit_code).returns(stub("process status", :success? => true))
+ presenter.expects(:`).with(includes("git log previous-sha..current-sha"))
+ presenter.scm_log_messages
+ end
end
-
- it "calls git log with previous_rev..current_rev" do
- capistrano = { :previous_revision => "previous-sha", :current_revision => "current-sha" }
- presenter = CapGun::Presenter.new(capistrano)
- presenter.stubs(:exit_code).returns(stub("process status", :success? => true))
- presenter.expects(:`).with(includes("git log previous-sha..current-sha"))
- presenter.git_log_messages
+ describe "with subversion" do
+ it "returns N/A if the svn log call returns an error" do
+ capistrano = {:scm => :subversion, :previous_revision => "42", :current_revision => "46" }
+ presenter = CapGun::Presenter.new(capistrano)
+ presenter.stubs(:`).returns("fatal: Not a working copy")
+ presenter.stubs(:exit_code).returns(stub("process status", :success? => false))
+ presenter.scm_log_messages.should == "N/A"
+ end
+
+ it "calls svn log with -r previous_rev+1:current_rev" do
+ capistrano = {:scm => :subversion, :previous_revision => "42", :current_revision => "46" }
+ presenter = CapGun::Presenter.new(capistrano)
+ presenter.stubs(:exit_code).returns(stub("process status", :success? => true))
+ presenter.expects(:`).with(includes("svn log -r 43:46"))
+ presenter.scm_log_messages
+ end
end
end
describe "release time" do
\ No newline at end of file