hub_test.rb 2.1 KB
Newer Older
1 2
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'helper'
C
Chris Wanstrath 已提交
3 4

class HubTest < Test::Unit::TestCase
5 6 7 8
  def setup
    Hub::Commands::USER.replace("tpw")
  end

C
Chris Wanstrath 已提交
9
  def test_private_clone
C
Chris Wanstrath 已提交
10 11 12
    input   = "clone -p rtomayko/ron"
    command = "git clone git@github.com:rtomayko/ron.git"
    assert_command input, command
C
Chris Wanstrath 已提交
13 14 15
  end

  def test_public_clone
C
Chris Wanstrath 已提交
16 17 18
    input   = "clone rtomayko/ron"
    command = "git clone git://github.com/rtomayko/ron.git"
    assert_command input, command
C
Chris Wanstrath 已提交
19 20
  end

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
  def test_your_private_clone
    input   = "clone -p resque"
    command = "git clone git@github.com:tpw/resque.git"
    assert_command input, command
  end

  def test_your_public_clone
    input   = "clone resque"
    command = "git clone git://github.com/tpw/resque.git"
    assert_command input, command
  end

  def test_private_clone_left_alone
    input   = "clone git@github.com:rtomayko/ron.git"
    command = "git clone git@github.com:rtomayko/ron.git"
    assert_command input, command
  end

  def test_public_clone_left_alone
    input   = "clone git://github.com/rtomayko/ron.git"
    command = "git clone git://github.com/rtomayko/ron.git"
    assert_command input, command
  end

C
Chris Wanstrath 已提交
45
  def test_private_remote
46
    input   = "remote add -p rtomayko"
C
Chris Wanstrath 已提交
47 48
    command = "git remote add rtomayko git@github.com:rtomayko/hub.git"
    assert_command input, command
C
Chris Wanstrath 已提交
49 50 51
  end

  def test_public_remote
52
    input   = "remote add rtomayko"
C
Chris Wanstrath 已提交
53 54
    command = "git remote add rtomayko git://github.com/rtomayko/hub.git"
    assert_command input, command
C
Chris Wanstrath 已提交
55 56 57
  end

  def test_init
C
Chris Wanstrath 已提交
58 59
    h = Hub("init -g")
    assert_equal "git init", h.command
60 61 62 63 64 65 66 67 68
    assert_equal "git remote add origin git@github.com:tpw/hub.git", h.after
  end

  def test_init_no_login
    out = hub("init -g") do
      Hub::Commands::USER.replace("")
    end

    assert_equal "** No GitHub user set. See http://github.com/guides/local-github-config\n", out
C
Chris Wanstrath 已提交
69 70 71
  end

  def test_version
C
terse  
Chris Wanstrath 已提交
72
    assert_equal "git version 1.6.4.2\nhub version 0.1.0\n", hub('--version')
C
Chris Wanstrath 已提交
73
  end
C
Chris Wanstrath 已提交
74 75 76 77 78 79 80 81

  def test_help
    assert_equal Hub::Commands.improved_help_text, hub("help")
  end

  def test_help_by_default
    assert_equal Hub::Commands.improved_help_text, hub("")
  end
C
Chris Wanstrath 已提交
82
end