automated-testing: more tests

This commit is contained in:
rkiel
2015-06-06 09:24:24 -04:00
parent 58221e9fea
commit b2f84629cf

View File

@@ -3,53 +3,80 @@ require 'minitest/autorun'
require_relative '../../../lib/shared/runnable'
describe Shared::Runnable do
include Shared::Runnable
class TestClass
include Shared::Runnable
end
describe "git commands" do
def run_cmd (cmd)
cmd
end
before do
@object = TestClass.new
@branch = "branch-name"
@run_cmd = lambda do |cmd|
cmd
end
end
it "should show branches" do
git_show_branches.must_equal "git branch"
@object.stub(:run_cmd, @run_cmd) do
@object.git_show_branches.must_equal "git branch"
end
end
it "should checkout" do
git_checkout(@branch).must_equal "git checkout branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_checkout(@branch).must_equal "git checkout branch-name"
end
end
it "should remote branch delete" do
git_remote_branch_delete(@branch).must_equal "git push origin :branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_remote_branch_delete(@branch).must_equal "git push origin :branch-name"
end
end
it "should local branch delete" do
git_local_branch_delete(@branch).must_equal "git branch -d branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_local_branch_delete(@branch).must_equal "git branch -d branch-name"
end
end
it "should local branch trash" do
git_local_branch_trash(@branch).must_equal "git branch -D branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_local_branch_trash(@branch).must_equal "git branch -D branch-name"
end
end
it "should prune remote branches" do
git_prune.must_equal "git remote prune origin"
@object.stub(:run_cmd, @run_cmd) do
@object.git_prune.must_equal "git remote prune origin"
end
end
it "should pull" do
git_pull(@branch).must_equal "git pull origin branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_pull(@branch).must_equal "git pull origin branch-name"
end
end
it "should merge" do
git_merge(@branch).must_equal "git merge branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_merge(@branch).must_equal "git merge branch-name"
end
end
it "should push" do
git_push(@branch).must_equal "git push origin branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_push(@branch).must_equal "git push origin branch-name"
end
end
it "should rebase" do
git_rebase(@branch).must_equal "git rebase branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_rebase(@branch).must_equal "git rebase branch-name"
end
end
it "should create local branch" do
git_local_branch_create(@branch).must_equal "git checkout -b branch-name"
@object.stub(:run_cmd, @run_cmd) do
@object.git_local_branch_create(@branch).must_equal "git checkout -b branch-name"
end
end
it "should commit" do
git_commit('test message').must_equal 'git commit -m "test message"'
@object.stub(:run_cmd, @run_cmd) do
@object.git_commit('test message').must_equal 'git commit -m "test message"'
end
end
end
end