Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the 2 pending specs

  • Loading branch information...
commit 3489bb06c1f1f3f1a3ca1d7dc5a93b130650b6b3 1 parent 011ffe5
@kballard kballard authored
View
14 commands/commands.rb
@@ -40,14 +40,22 @@
desc "Track another user's repository."
flags :private => "Use git@github.com: instead of git://github.com/."
-command :track do |user|
+command :track do |remote, user|
+ # track remote user
+ # track remote user/repo
+ # track user
+ # track user/repo
+ user, remote = remote, nil if user.nil?
die "Specify a user to track" if user.nil?
+ user, repo = user.split("/", 2)
die "Already tracking #{user}" if helper.tracking?(user)
+ repo = @helper.project if repo.nil?
+ repo.chomp!(".git")
if options[:private]
- git "remote add #{user} #{helper.private_url_for(user)}"
+ git "remote add #{user} #{helper.private_url_for_user_and_repo(user, repo)}"
else
- git "remote add #{user} #{helper.public_url_for(user)}"
+ git "remote add #{user} #{helper.public_url_for_user_and_repo(user, repo)}"
end
end
View
12 commands/helpers.rb
@@ -81,12 +81,20 @@
user_and_branch.last
end
+helper :public_url_for_user_and_repo do |user, repo|
+ "git://github.com/#{user}/#{repo}.git"
+end
+
+helper :private_url_for_user_and_repo do |user, repo|
+ "git@github.com:#{user}/#{repo}.git"
+end
+
helper :public_url_for do |user|
- "git://github.com/#{user}/#{project}.git"
+ public_url_for_user_and_repo user, project
end
helper :private_url_for do |user|
- "git@github.com:#{user}/#{project}.git"
+ private_url_for_user_and_repo user, project
end
helper :homepage_for do |user, branch|
View
30 spec/helper_spec.rb
@@ -35,12 +35,33 @@ def self.helper(name, &block)
end
helper :private_url_for do
- it "should return ssh-style url" do
+ it "should return an ssh-style url" do
setup_url_for :origin, "user", "merb-core"
@helper.private_url_for("wycats").should == "git@github.com:wycats/merb-core.git"
end
end
+ helper :private_url_for_user_and_repo do
+ it "should return an ssh-style url" do
+ @helper.should_not_receive(:project)
+ @helper.private_url_for_user_and_repo("defunkt", "github-gem").should == "git@github.com:defunkt/github-gem.git"
+ end
+ end
+
+ helper :public_url_for do
+ it "should return a git:// URL" do
+ setup_url_for :origin, "user", "merb-core"
+ @helper.public_url_for("wycats").should == "git://github.com/wycats/merb-core.git"
+ end
+ end
+
+ helper :public_url_for_user_and_repo do
+ it "should return a git:// URL" do
+ @helper.should_not_receive(:project)
+ @helper.public_url_for_user_and_repo("defunkt", "github-gem").should == "git://github.com/defunkt/github-gem.git"
+ end
+ end
+
helper :project do
it "should return project-awesome" do
setup_url_for :origin, "user", "project-awesome"
@@ -60,13 +81,6 @@ def self.helper(name, &block)
end
end
- helper :public_url_for do
- it "should return git:// URL" do
- setup_url_for :origin, "user", "merb-core"
- @helper.public_url_for("wycats").should == "git://github.com/wycats/merb-core.git"
- end
- end
-
helper :repo_for do
it "should return mephisto.git" do
setup_url_for :mojombo, "mojombo", "mephisto"
View
24 spec/ui_spec.rb
@@ -114,24 +114,20 @@
end
specify "track should accept user/project syntax" do
- pending do
- running :track, "defunkt/github-gem.git" do
- setup_url_for
- @helper.should_receive(:tracking?).with("defunkt").and_return false
- @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/github-gem.git")
- end
+ running :track, "defunkt/github-gem.git" do
+ setup_url_for
+ @helper.should_receive(:tracking?).with("defunkt").and_return false
+ @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/github-gem.git")
end
end
specify "track defunkt/github-gem.git should function with no origin remote" do
- pending do
- running :track, "defunkt/github-gem.git" do
- @helper.stub!(:url_for).with(:origin).and_return ""
- @helper.stub!(:tracking?).and_return false
- @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/github-gem.git")
- self.should_not raise_error(SystemExit)
- stderr.should_not =~ /^Error/
- end
+ running :track, "defunkt/github-gem.git" do
+ @helper.stub!(:url_for).with(:origin).and_return ""
+ @helper.stub!(:tracking?).and_return false
+ @command.should_receive(:git).with("remote add defunkt git://github.com/defunkt/github-gem.git")
+ self.should_not raise_error(SystemExit)
+ stderr.should_not =~ /^Error/
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.