drnic-github 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github home" do
5
+ include CommandHelper
6
+
7
+ specify "home should open the project home page" do
8
+ running :home do
9
+ setup_url_for
10
+ @helper.should_receive(:open).once.with("https://github.com/user/project/tree/master")
11
+ end
12
+ end
13
+
14
+ specify "home defunkt should open the home page of defunkt's fork" do
15
+ running :home, "defunkt" do
16
+ setup_url_for
17
+ @helper.should_receive(:open).once.with("https://github.com/defunkt/project/tree/master")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github info" do
5
+ include CommandHelper
6
+
7
+ specify "info should show info for this project" do
8
+ running :info do
9
+ setup_url_for
10
+ setup_remote(:origin, :user => "user", :ssh => true)
11
+ setup_remote(:defunkt)
12
+ setup_remote(:external, :url => "home:/path/to/project.git")
13
+ stdout.should == <<-EOF
14
+ == Info for project
15
+ You are user
16
+ Currently tracking:
17
+ - defunkt (as defunkt)
18
+ - home:/path/to/project.git (as external)
19
+ - user (as origin)
20
+ EOF
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github network" do
5
+ include CommandHelper
6
+
7
+ specify "network should open the network page for this repo" do
8
+ running :network, 'web' do
9
+ setup_url_for
10
+ @helper.should_receive(:open).once.with("https://github.com/user/project/network")
11
+ end
12
+ end
13
+
14
+ specify "network defunkt should open the network page for defunkt's fork" do
15
+ running :network, 'web', "defunkt" do
16
+ setup_url_for
17
+ @helper.should_receive(:open).once.with("https://github.com/defunkt/project/network")
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github pull-request" do
5
+ include CommandHelper
6
+
7
+ specify "pull-request should die with no args" do
8
+ running :'pull-request' do
9
+ setup_url_for
10
+ @command.should_receive(:die).with("Specify a user for the pull request").and_return { raise "Died" }
11
+ self.should raise_error(RuntimeError)
12
+ end
13
+ end
14
+
15
+ specify "pull-request user should track user if untracked" do
16
+ running :'pull-request', "user" do
17
+ setup_url_for
18
+ setup_remote :origin, :user => "kballard"
19
+ setup_remote :defunkt
20
+ GitHub.should_receive(:invoke).with(:track, "user").and_return { raise "Tracked" }
21
+ self.should raise_error("Tracked")
22
+ end
23
+ end
24
+
25
+ specify "pull-request user/branch should generate a pull request" do
26
+ running :'pull-request', "user/branch" do
27
+ setup_url_for
28
+ setup_remote :origin, :user => "kballard"
29
+ setup_remote :user
30
+ @command.should_receive(:git_exec).with("request-pull user/branch origin")
31
+ end
32
+ end
33
+
34
+ specify "pull-request user should generate a pull request with branch master" do
35
+ running :'pull-request', "user" do
36
+ setup_url_for
37
+ setup_remote :origin, :user => "kballard"
38
+ setup_remote :user
39
+ @command.should_receive(:git_exec).with("request-pull user/master origin")
40
+ end
41
+ end
42
+
43
+ specify "pull-request user branch should generate a pull request" do
44
+ running:'pull-request', "user", "branch" do
45
+ setup_url_for
46
+ setup_remote :origin, :user => "kballard"
47
+ setup_remote :user
48
+ @command.should_receive(:git_exec).with("request-pull user/branch origin")
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github pull" do
5
+ include CommandHelper
6
+
7
+ specify "pull defunkt should start tracking defunkt if they're not already tracked" do
8
+ running :pull, "defunkt" do
9
+ mock_members 'defunkt'
10
+ setup_remote(:origin, :user => "user", :ssh => true)
11
+ setup_remote(:external, :url => "home:/path/to/project.git")
12
+ GitHub.should_receive(:invoke).with(:track, "defunkt").and_return { raise "Tracked" }
13
+ self.should raise_error("Tracked")
14
+ end
15
+ end
16
+
17
+ specify "pull defunkt should create defunkt/master and pull from the defunkt remote" do
18
+ running :pull, "defunkt" do
19
+ mock_members 'defunkt'
20
+ setup_remote(:defunkt)
21
+ @helper.should_receive(:branch_dirty?).and_return false
22
+ @command.should_receive(:git).with("fetch defunkt").ordered
23
+ @command.should_receive(:git_exec).with("checkout -b defunkt/master defunkt/master").ordered
24
+ stdout.should == "Switching to defunkt-master\n"
25
+ end
26
+ end
27
+
28
+ specify "pull defunkt should switch to pre-existing defunkt/master and pull from the defunkt remote" do
29
+ running :pull, "defunkt" do
30
+ mock_members 'defunkt'
31
+ setup_remote(:defunkt)
32
+ @helper.should_receive(:branch_dirty?).and_return true
33
+ @command.should_receive(:die).with("Unable to switch branches, your current branch has uncommitted changes").and_return { raise "Died" }
34
+ self.should raise_error(RuntimeError)
35
+ end
36
+ end
37
+
38
+ specify "pull defunkt wip should create defunkt/wip and pull from wip branch on defunkt remote" do
39
+ running :pull, "defunkt", "wip" do
40
+ mock_members 'defunkt'
41
+ setup_remote(:defunkt)
42
+ @helper.should_receive(:branch_dirty?).and_return true
43
+ @command.should_receive(:die).with("Unable to switch branches, your current branch has uncommitted changes").and_return { raise "Died" }
44
+ self.should raise_error(RuntimeError)
45
+ end
46
+ end
47
+
48
+ specify "pull defunkt/wip should switch to pre-existing defunkt/wip and pull from wip branch on defunkt remote" do
49
+ running :pull, "defunkt/wip" do
50
+ mock_members 'defunkt'
51
+ setup_remote(:defunkt)
52
+ @helper.should_receive(:branch_dirty?).and_return false
53
+ @command.should_receive(:git).with("fetch defunkt").ordered
54
+ @command.should_receive(:git_exec).with("checkout -b defunkt/wip defunkt/wip").ordered
55
+ stdout.should == "Switching to defunkt-wip\n"
56
+ end
57
+ end
58
+
59
+ specify "pull --merge defunkt should pull from defunkt remote into current branch" do
60
+ running :pull, "--merge", "defunkt" do
61
+ mock_members 'defunkt'
62
+ setup_remote(:defunkt)
63
+ @helper.should_receive(:branch_dirty?).and_return false
64
+ @command.should_receive(:git_exec).with("pull defunkt master")
65
+ end
66
+ end
67
+
68
+ specify "pull falls through for non-recognized commands" do
69
+ running :pull, 'remote' do
70
+ mock_members 'defunkt'
71
+ setup_remote(:defunkt)
72
+ @command.should_receive(:git_exec).with("pull remote")
73
+ end
74
+ end
75
+
76
+ specify "pull passes along args when falling through" do
77
+ running :pull, 'remote', '--stat' do
78
+ mock_members 'defunkt'
79
+ @command.should_receive(:git_exec).with("pull remote --stat")
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github search" do
5
+ include CommandHelper
6
+
7
+ specify "search finds multiple results" do
8
+ running :search, "github-gem" do
9
+ json = StringIO.new '{"repositories":[' +
10
+ '{"name":"github-gem","size":300,"followers":499,"username":"defunkt","language":"Ruby","fork":false,"id":"repo-1653","type":"repo","pushed":"2008-12-04T03:14:00Z","forks":59,"description":"The official `github` command line helper for simplifying your GitHub experience.","score":3.4152448,"created":"2008-02-28T09:35:34Z"},' +
11
+ '{"name":"github-gem-builder","size":76,"followers":26,"username":"pjhyett","language":"Ruby","fork":false,"id":"repo-67489","type":"repo","pushed":"2008-11-04T04:54:57Z","forks":3,"description":"The scripts used to build RubyGems on GitHub","score":3.4152448,"created":"2008-10-24T22:29:32Z"}' +
12
+ ']}'
13
+ json.rewind
14
+ @command.should_receive(:open).with("http://github.com/api/v1/json/search/github-gem").and_return(json)
15
+ stdout.should == "defunkt/github-gem\npjhyett/github-gem-builder\n"
16
+ end
17
+ end
18
+
19
+ specify "search finds no results" do
20
+ running :search, "xxxxxxxxxx" do
21
+ json = StringIO.new '{"repositories":[]}'
22
+ json.rewind
23
+ @command.should_receive(:open).with("http://github.com/api/v1/json/search/xxxxxxxxxx").and_return(json)
24
+ stdout.should == "No results found\n"
25
+ end
26
+ end
27
+
28
+ specify "search shows usage if no arguments given" do
29
+ running :search do
30
+ @command.should_receive(:die).with("Usage: github search [query]").and_return { raise "Died" }
31
+ self.should raise_error(RuntimeError)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.dirname(__FILE__) + '/command_helper'
3
+
4
+ describe "github track" do
5
+ include CommandHelper
6
+
7
+ specify "track defunkt should track a new remote for defunkt" do
8
+ running :track, "defunkt" do
9
+ setup_url_for
10
+ @helper.should_receive(:tracking?).with("defunkt").once.and_return(false)
11
+ @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/project.git").once
12
+ end
13
+ end
14
+
15
+ specify "track --private defunkt should track a new remote for defunkt using ssh" do
16
+ running :track, "--private", "defunkt" do
17
+ setup_url_for
18
+ @helper.should_receive(:tracking?).with("defunkt").and_return(false)
19
+ @command.should_receive(:git).with("remote add defunkt git@github.com:defunkt/project.git")
20
+ end
21
+ end
22
+
23
+ specify "track --ssh defunkt should be equivalent to track --private defunkt" do
24
+ running :track, "--ssh", "defunkt" do
25
+ setup_url_for
26
+ @helper.should_receive(:tracking?).with("defunkt").and_return(false)
27
+ @command.should_receive(:git).with("remote add defunkt git@github.com:defunkt/project.git")
28
+ end
29
+ end
30
+
31
+ specify "track defunkt should die if the defunkt remote exists" do
32
+ running :track, "defunkt" do
33
+ setup_url_for
34
+ @helper.should_receive(:tracking?).with("defunkt").once.and_return(true)
35
+ @command.should_receive(:die).with("Already tracking defunkt").and_return { raise "Died" }
36
+ self.should raise_error(RuntimeError)
37
+ end
38
+ end
39
+
40
+ specify "track should die with no args" do
41
+ running :track do
42
+ @command.should_receive(:die).with("Specify a user to track").and_return { raise "Died" }
43
+ self.should raise_error(RuntimeError)
44
+ end
45
+ end
46
+
47
+ specify "track should accept user/project syntax" do
48
+ running :track, "defunkt/github-gem.git" do
49
+ setup_url_for
50
+ @helper.should_receive(:tracking?).with("defunkt").and_return false
51
+ @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/github-gem.git")
52
+ end
53
+ end
54
+
55
+ specify "track defunkt/github-gem.git should function with no origin remote" do
56
+ running :track, "defunkt/github-gem.git" do
57
+ @helper.stub!(:url_for).with("origin").and_return ""
58
+ @helper.stub!(:tracking?).and_return false
59
+ @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/github-gem.git")
60
+ self.should_not raise_error(SystemExit)
61
+ stderr.should_not =~ /^Error/
62
+ end
63
+ end
64
+
65
+ specify "track origin defunkt/github-gem should track defunkt/github-gem as the origin remote" do
66
+ running :track, "origin", "defunkt/github-gem" do
67
+ @helper.stub!(:url_for).with("origin").and_return ""
68
+ @helper.stub!(:tracking?).and_return false
69
+ @command.should_receive(:git).with("remote add origin git://github.com/defunkt/github-gem.git")
70
+ stderr.should_not =~ /^Error/
71
+ end
72
+ end
73
+
74
+ specify "track --private origin defunkt/github-gem should track defunkt/github-gem as the origin remote using ssh" do
75
+ running :track, "--private", "origin", "defunkt/github-gem" do
76
+ @helper.stub!(:url_for).with("origin").and_return ""
77
+ @helper.stub!(:tracking?).and_return false
78
+ @command.should_receive(:git).with("remote add origin git@github.com:defunkt/github-gem.git")
79
+ stderr.should_not =~ /^Error/
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require File.dirname(__FILE__) + '/commands/command_helper'
3
+
4
+ describe "github" do
5
+ include CommandHelper
6
+
7
+ # -- fallthrough to git if unknown command --
8
+ specify "should fall through to actual git commands" do
9
+ running :commit do
10
+ @command.should_receive(:git_exec).with(["commit", []])
11
+ end
12
+ end
13
+
14
+ specify "should pass along arguments when falling through" do
15
+ running :commit, '-a', '-m', 'yo mama' do
16
+ @command.should_receive(:git_exec).with(["commit", ["-a", "-m", 'yo mama']])
17
+ end
18
+ end
19
+
20
+ # -- default --
21
+ specify "should print the default message" do
22
+ running :default do
23
+ GitHub.should_receive(:descriptions).any_number_of_times.and_return({
24
+ "home" => "Open the home page",
25
+ "browsing" => "Browse the github page for this branch",
26
+ "commands" => "description",
27
+ "tracking" => "Track a new repo"
28
+ })
29
+ GitHub.should_receive(:flag_descriptions).any_number_of_times.and_return({
30
+ "home" => {:flag => "Flag description"},
31
+ "browsing" => {},
32
+ "commands" => {},
33
+ "tracking" => {:flag1 => "Flag one", :flag2 => "Flag two"}
34
+ })
35
+ @command.should_receive(:puts).with(<<-EOS.gsub(/^ /, ''))
36
+ Usage: github command <space separated arguments>
37
+ Available commands:
38
+ browsing => Browse the github page for this branch
39
+ commands => description
40
+ home => Open the home page
41
+ --flag: Flag description
42
+ tracking => Track a new repo
43
+ --flag1: Flag one
44
+ --flag2: Flag two
45
+ EOS
46
+ end
47
+ end
48
+
49
+ end
@@ -31,6 +31,22 @@ describe GitHub::Helper do
31
31
  @helper = GitHub::Helper.new
32
32
  end
33
33
 
34
+ helper :format_list do
35
+ it "should format an array of hashes with name,description keys" do
36
+ list = [{"name" => "aaa", "description" => "description for aaa"},
37
+ {"name" => "a long name", "description" => "help"},
38
+ {"name" => "no desc"},
39
+ {"name" => "empty desc", "description" => ""}]
40
+ expected = <<-EOS.gsub(/^ /, '')
41
+ aaa # description for aaa
42
+ a long name # help
43
+ no desc
44
+ empty desc
45
+ EOS
46
+ @helper.format_list(list).should == expected.gsub(/\n$/,'')
47
+ end
48
+ end
49
+
34
50
  helper :print_issues_help do
35
51
  it "should exist" do
36
52
  @helper.should respond_to(:print_issues_help)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drnic-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath, Kevin Ballard, Scott Chacon
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-04 00:00:00 +10:00
12
+ date: 2009-11-05 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,17 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
23
+ version: 1.0.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: highline
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.1
24
34
  version:
25
35
  description: The official `github` command line helper for simplifying your GitHub experience.
26
36
  email: chris@ozmm.org
@@ -51,7 +61,6 @@ files:
51
61
  - Rakefile
52
62
  - bin/gh
53
63
  - bin/github
54
- - github.gemspec
55
64
  - lib/commands/commands.rb
56
65
  - lib/commands/helpers.rb
57
66
  - lib/commands/issues.rb
@@ -63,12 +72,26 @@ files:
63
72
  - lib/github/ui.rb
64
73
  - setup.rb
65
74
  - spec/command_spec.rb
75
+ - spec/commands/command_browse_spec.rb
76
+ - spec/commands/command_clone_spec.rb
77
+ - spec/commands/command_create-from-local_spec.rb
78
+ - spec/commands/command_fetch_spec.rb
79
+ - spec/commands/command_fork_spec.rb
80
+ - spec/commands/command_helper.rb
81
+ - spec/commands/command_home_spec.rb
82
+ - spec/commands/command_info_spec.rb
83
+ - spec/commands/command_network_spec.rb
84
+ - spec/commands/command_pull-request_spec.rb
85
+ - spec/commands/command_pull_spec.rb
86
+ - spec/commands/command_search_spec.rb
87
+ - spec/commands/command_track_spec.rb
88
+ - spec/commands_spec.rb
66
89
  - spec/extensions_spec.rb
67
90
  - spec/github_spec.rb
68
91
  - spec/helper_spec.rb
69
92
  - spec/spec_helper.rb
70
- - spec/ui_spec.rb
71
93
  - spec/windoze_spec.rb
94
+ - github.gemspec
72
95
  has_rdoc: true
73
96
  homepage: http://github.com/
74
97
  licenses: []