Permalink
Browse files

rewrite `alias` tests as cukes

  • Loading branch information...
mislav committed May 8, 2012
1 parent 1f41284 commit 9e51a5f063ba65a5eda4dc8a34283ecfeb67c4ff
Showing with 50 additions and 59 deletions.
  1. +50 −0 features/alias.feature
  2. +0 −59 test/alias_test.rb
View
@@ -0,0 +1,50 @@
+Feature: hub alias
+
+ Scenario: bash instructions
+ Given $SHELL is "/bin/bash"
+ When I successfully run `hub alias`
+ Then the output should contain exactly:
+ """
+ # Wrap git automatically by adding the following to ~/.bash_profile:
+
+ eval "$(hub alias -s)"\n
+ """
+
+ Scenario: zsh instructions
+ Given $SHELL is "/bin/zsh"
+ When I successfully run `hub alias`
+ Then the output should contain exactly:
+ """
+ # Wrap git automatically by adding the following to ~/.zshrc:
+
+ eval "$(hub alias -s)"\n
+ """
+
+ Scenario: bash code
+ Given $SHELL is "/bin/bash"
+ When I successfully run `hub alias -s`
+ Then the output should contain exactly:
+ """
+ alias git=hub\n
+ """
+
+ Scenario: zsh code
+ Given $SHELL is "/bin/zsh"
+ When I successfully run `hub alias -s`
+ Then the output should contain exactly:
+ """
+ alias git=hub
+ if type compdef >/dev/null; then
+ compdef hub=git
+ fi\n
+ """
+
+ Scenario: unsupported shell
+ Given $SHELL is "/bin/zwoosh"
+ When I run `hub alias -s`
+ Then the output should contain exactly:
+ """
+ hub alias: unsupported shell
+ supported shells: bash zsh sh ksh csh fish\n
+ """
+ And the exit status should be 1
View
@@ -1,59 +0,0 @@
-require 'helper'
-
-class AliasTest < Test::Unit::TestCase
- 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_instructions_bash
- with_shell('bash') do
- assert_includes '~/.bash_profile', hub("alias")
- end
- end
-
- def test_alias_instructions_zsh
- with_shell('zsh') do
- assert_includes '~/.zshrc', hub("alias")
- end
- end
-
- def test_alias_script_bash
- with_shell('bash') do
- assert_equal "alias git=hub\n", hub("alias -s")
- end
- end
-
- 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_unknown_shell
- with_shell(nil) do
- assert_equal "hub alias: unknown shell\n", hub("alias -s")
- end
- end
-
- 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
-
- private
-
- def with_shell(shell)
- old_shell, ENV['SHELL'] = ENV['SHELL'], shell
- yield
- ensure
- ENV['SHELL'] = old_shell
- end
-end

0 comments on commit 9e51a5f

Please sign in to comment.