./test/dolt/git/shell_test.rb in dolt-0.1.0 vs ./test/dolt/git/shell_test.rb in dolt-0.1.1
- old
+ new
@@ -22,57 +22,91 @@
describe Dolt::Git::Shell do
include EM::MiniTest::Spec
include Dolt::StdioStub
- it "assumes git dir in work tree" do
- expected_cmd = ["git --git-dir /somewhere/.git ",
- "--work-tree /somewhere log"].join
- Dolt::DeferrableChildProcess.expects(:open).with(expected_cmd)
- git = Dolt::Git::Shell.new("/somewhere")
- git.git("log")
- end
+ describe "#git" do
+ it "assumes git dir in work tree" do
+ expected_cmd = ["git --git-dir /somewhere/.git ",
+ "--work-tree /somewhere log"].join
+ Dolt::DeferrableChildProcess.expects(:open).with(expected_cmd)
+ git = Dolt::Git::Shell.new("/somewhere")
+ git.git("log")
+ end
- it "uses provided git dir" do
- expected_cmd = ["git --git-dir /somewhere/.git ",
- "--work-tree /elsewhere log"].join
- Dolt::DeferrableChildProcess.expects(:open).with(expected_cmd)
- git = Dolt::Git::Shell.new("/elsewhere", "/somewhere/.git")
- git.git("log")
- end
+ it "uses provided git dir" do
+ expected_cmd = ["git --git-dir /somewhere/.git ",
+ "--work-tree /elsewhere log"].join
+ Dolt::DeferrableChildProcess.expects(:open).with(expected_cmd)
+ git = Dolt::Git::Shell.new("/elsewhere", "/somewhere/.git")
+ git.git("log")
+ end
- it "returns deferrable" do
- silence_stderr do
- git = Dolt::Git::Shell.new("/somwhere")
- result = git.git("log")
+ it "returns deferrable" do
+ silence_stderr do
+ git = Dolt::Git::Shell.new("/somwhere")
+ result = git.git("log")
- assert result.respond_to?(:callback)
- assert result.respond_to?(:errback)
+ assert result.respond_to?(:callback)
+ assert result.respond_to?(:errback)
+ end
end
- end
- it "joins arguments with spaces" do
- expected_cmd = ["git --git-dir /somewhere/.git ",
- "--work-tree /somewhere push origin master"].join
- Dolt::DeferrableChildProcess.expects(:open).with(expected_cmd)
- git = Dolt::Git::Shell.new("/somewhere")
- git.git("push", "origin", "master")
+ it "joins arguments with spaces" do
+ expected_cmd = ["git --git-dir /somewhere/.git ",
+ "--work-tree /somewhere push origin master"].join
+ Dolt::DeferrableChildProcess.expects(:open).with(expected_cmd)
+ git = Dolt::Git::Shell.new("/somewhere")
+ git.git("push", "origin", "master")
+ end
+
+ it "calls errback when git operation fails" do
+ silence_stderr do
+ git = Dolt::Git::Shell.new("/somewhere")
+ result = git.git("push", "origin", "master")
+ result.errback do |status|
+ refute status.nil?
+ done!
+ end
+ wait!
+ end
+ end
end
- it "calls errback when git operation fails" do
- silence_stderr do
+ describe "#show" do
+ it "shows a file" do
git = Dolt::Git::Shell.new("/somewhere")
- result = git.git("push", "origin", "master")
- result.errback do |status|
- refute status.nil?
- done!
- end
- wait!
+ git.expects(:git).with("show", "master:app/models/repository.rb")
+ result = git.show("app/models/repository.rb", "master")
end
end
- it "shows a file" do
- git = Dolt::Git::Shell.new("/somewhere")
- git.expects(:git).with("show", "master:app/models/repository.rb")
- result = git.show("app/models/repository.rb", "master")
+ describe "#ls_tree" do
+ it "lists tree root" do
+ git = Dolt::Git::Shell.new("/somewhere")
+ git.expects(:git).with("ls-tree", "master", "./")
+
+ result = git.ls_tree("", "master")
+ end
+
+ it "lists tree root when starting with slash" do
+ git = Dolt::Git::Shell.new("/somewhere")
+ git.expects(:git).with("ls-tree", "master", "./")
+
+ result = git.ls_tree("/", "master")
+ end
+
+ it "lists path with trailing slash" do
+ git = Dolt::Git::Shell.new("/somewhere")
+ git.expects(:git).with("ls-tree", "master", "./app/models/")
+
+ result = git.ls_tree("app/models", "master")
+ end
+
+ it "lists path at given ref" do
+ git = Dolt::Git::Shell.new("/somewhere")
+ git.expects(:git).with("ls-tree", "v2.0.0", "./app/models/")
+
+ result = git.ls_tree("app/models/", "v2.0.0")
+ end
end
end