basic install tests passing for shells

This commit is contained in:
Chris Wanstrath 2009-12-08 02:35:22 -08:00
Родитель e48d374bf6
Коммит c66ecfe028
3 изменённых файлов: 48 добавлений и 8 удалений

Просмотреть файл

@ -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