forked from mislav/hub
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
84 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,59 @@ | ||
require 'helper' | ||
|
||
class AliasTest < Test::Unit::TestCase | ||
def test_alias | ||
instructions = hub("alias") | ||
assert_includes "bash", instructions | ||
assert_includes "sh", instructions | ||
assert_includes "csh", instructions | ||
assert_includes "zsh", instructions | ||
assert_includes "fish", instructions | ||
def test_alias_instructions | ||
expected = "# Wrap git automatically by adding the following to your profile:\n" | ||
expected << "\n" | ||
expected << 'eval "$(hub alias -s)"' << "\n" | ||
assert_equal expected, hub("alias sh") | ||
end | ||
|
||
def test_alias_silent | ||
assert_equal "alias git=hub\n", hub("alias -s bash") | ||
def test_alias_instructions_bash | ||
with_shell('bash') do | ||
assert_includes '~/.bash_profile', hub("alias") | ||
end | ||
end | ||
|
||
def test_alias_bash | ||
assert_alias_command "bash", "alias git=hub" | ||
def test_alias_instructions_zsh | ||
with_shell('zsh') do | ||
assert_includes '~/.zshrc', hub("alias") | ||
end | ||
end | ||
|
||
def test_alias_sh | ||
assert_alias_command "sh", "alias git=hub" | ||
def test_alias_script_bash | ||
with_shell('bash') do | ||
assert_equal "alias git=hub\n", hub("alias -s") | ||
end | ||
end | ||
|
||
def test_alias_zsh | ||
assert_alias_command "zsh", 'function git(){hub "$@"}' | ||
def test_alias_script_zsh | ||
with_shell('zsh') do | ||
script = hub("alias -s") | ||
assert_includes "alias git=hub\n", script | ||
assert_includes "compdef hub=git\n", script | ||
end | ||
end | ||
|
||
def test_alias_csh | ||
assert_alias_command "csh", "alias git hub" | ||
def test_unknown_shell | ||
with_shell(nil) do | ||
assert_equal "hub alias: unknown shell\n", hub("alias -s") | ||
end | ||
end | ||
|
||
def test_alias_fish | ||
assert_alias_command "fish", "alias git hub" | ||
def test_unsupported_shell | ||
with_shell('foosh') do | ||
expected = "hub alias: unsupported shell\n" | ||
expected << "supported shells: bash zsh sh ksh csh fish\n" | ||
assert_equal expected, hub("alias -s") | ||
end | ||
end | ||
|
||
def test_alias_blah | ||
assert_alias_command "blah", "fatal: never heard of `blah'" | ||
private | ||
|
||
def with_shell(shell) | ||
old_shell, ENV['SHELL'] = ENV['SHELL'], shell | ||
yield | ||
ensure | ||
ENV['SHELL'] = old_shell | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters