public
Rubygem
Description: The official `github` command line helper for simplifying your GitHub experience.
Homepage: http://github.com
Clone URL: git://github.com/defunkt/github-gem.git
Search Repo:
defunkt (author)
Sun May 11 19:32:43 -0700 2008
commit  af8cfb367df0a76aec274c16af26936bcb9de1da
tree    c03f6c824e3961f8bf81f30a1da45cfe85a965b1
parent  a4452cb0f150a63e6c417dbabbc56fff8f59094c parent  bf1aaf6cca044b58bf74c2d7eaddb04764cb90dd
github-gem / spec / helpers / user_and_repo_from_spec.rb
100644 38 lines (30 sloc) 1.543 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require File.dirname(__FILE__) + '/../spec_helper'
 
describe "The user_and_repo_from helper" do
  before(:each) do
    @helper = GitHub::Helper.new
  end
 
  it "should parse a git:// url" do
    @helper.user_and_repo_from("git://github.com/defunkt/github.git").should == ["defunkt", "github.git"]
  end
 
  it "should parse a ssh-based url" do
    @helper.user_and_repo_from("git@github.com:mojombo/god.git").should == ["mojombo", "god.git"]
  end
 
  it "should parse a non-standard ssh-based url" do
    @helper.user_and_repo_from("ssh://git@github.com:mojombo/god.git").should == ["mojombo", "god.git"]
    @helper.user_and_repo_from("github.com:mojombo/god.git").should == ["mojombo", "god.git"]
    @helper.user_and_repo_from("ssh://github.com:mojombo/god.git").should == ["mojombo", "god.git"]
  end
 
  it "should return nothing for other urls" do
    @helper.user_and_repo_from("home:path/to/repo.git").should == ['', '']
  end
 
  it "should return nothing for invalid git:// urls" do
    @helper.user_and_repo_from("git://github.com/foo").should == ['', '']
  end
 
  it "should return nothing for invalid ssh-based urls" do
    @helper.user_and_repo_from("git@github.com:kballard").should == ['', '']
    @helper.user_and_repo_from("git@github.com:kballard/test/repo.git").should == ['', '']
    @helper.user_and_repo_from("ssh://git@github.com:kballard").should == ['', '']
    @helper.user_and_repo_from("github.com:kballard").should == ['', '']
    @helper.user_and_repo_from("ssh://github.com:kballard").should == ['', '']
  end
end