提交 c66ecfe0 编写于 作者: C Chris Wanstrath

basic install tests passing for shells

上级 e48d374b
......@@ -89,7 +89,17 @@ module Hub
'fish' => 'alias git hub'
}
shell = args[1]
if shell = args[1]
puts "Run this in your shell to start using `hub` as `git`:"
print " "
else
puts "usage: hub install SHELL", ""
puts "known shells:"
shells.map { |key, _| key }.sort.each do |key|
puts " " + key
end
exit
end
if shells[shell]
puts shells[shell]
......@@ -162,7 +172,7 @@ help
# All calls to `puts` in after hooks or commands are paged,
# git-style.
def puts(content)
def puts(*args)
page_stdout
super
end
......
......@@ -44,4 +44,25 @@ class Test::Unit::TestCase
def assert_command(input, expected)
assert_equal expected, Hub(input).command
end
# Asserts that `hub` will show a specific installation command for a
# specific shell.
#
# e.g.
# assert_install_command "sh", "alias git=hub"
#
# Here we are saying that this:
# $ hub install sh
# Should display this:
# Run this in your shell to start using `hub` as `git`:
# alias git=hub
def assert_install_command(shell, command)
expected = "Run this in your shell to start using `hub` as `git`:\n %s\n"
assert_equal(expected % command, hub("install #{shell}"))
end
# Asserts that `haystack` includes `needle`.
def assert_includes(needle, haystack)
assert haystack.include?(needle)
end
end
......@@ -2,27 +2,36 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
require 'helper'
class InstallTest < Test::Unit::TestCase
def test_install
instructions = hub("install")
assert_includes "bash", instructions
assert_includes "sh", instructions
assert_includes "csh", instructions
assert_includes "zsh", instructions
assert_includes "fish", instructions
end
def test_install_bash
assert_equal "alias git=hub\n", hub("install bash")
assert_install_command "bash", "alias git=hub"
end
def test_install_sh
assert_equal "alias git=hub\n", hub("install sh")
assert_install_command "sh", "alias git=hub"
end
def test_install_zsh
assert_equal "alias git=hub\n", hub("install zsh")
assert_install_command "zsh", "alias git=hub"
end
def test_install_csh
assert_equal "alias git hub\n", hub("install csh")
assert_install_command "csh", "alias git hub"
end
def test_install_fish
assert_equal "alias git hub\n", hub("install fish")
assert_install_command "fish", "alias git hub"
end
def test_install_blah
assert_equal "fatal: never heard of `blah'\n", hub("install blah")
assert_install_command "blah", "fatal: never heard of `blah'"
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册