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

class HubTest < Test::Unit::TestCase
  def test_private_clone
C
Chris Wanstrath 已提交
6 7 8
    input   = "clone -p rtomayko/ron"
    command = "git clone git@github.com:rtomayko/ron.git"
    assert_command input, command
C
Chris Wanstrath 已提交
9 10 11
  end

  def test_public_clone
C
Chris Wanstrath 已提交
12 13 14
    input   = "clone rtomayko/ron"
    command = "git clone git://github.com/rtomayko/ron.git"
    assert_command input, command
C
Chris Wanstrath 已提交
15 16 17
  end

  def test_private_remote
18
    input   = "remote add -p rtomayko"
C
Chris Wanstrath 已提交
19 20
    command = "git remote add rtomayko git@github.com:rtomayko/hub.git"
    assert_command input, command
C
Chris Wanstrath 已提交
21 22 23
  end

  def test_public_remote
24
    input   = "remote add rtomayko"
C
Chris Wanstrath 已提交
25 26
    command = "git remote add rtomayko git://github.com/rtomayko/hub.git"
    assert_command input, command
C
Chris Wanstrath 已提交
27 28 29
  end

  def test_init
30
    Hub::Commands::USER.replace("tpw")
C
Chris Wanstrath 已提交
31 32
    h = Hub("init -g")
    assert_equal "git init", h.command
33 34 35 36 37 38 39 40 41
    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 已提交
42 43 44
  end

  def test_version
C
terse  
Chris Wanstrath 已提交
45
    assert_equal "git version 1.6.4.2\nhub version 0.1.0\n", hub('--version')
C
Chris Wanstrath 已提交
46
  end
C
Chris Wanstrath 已提交
47 48 49 50 51 52 53 54

  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 已提交
55
end