Skip to content

Commit

Permalink
Fix the 2 pending specs
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyball committed Jun 1, 2008
1 parent 011ffe5 commit 3489bb0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
14 changes: 11 additions & 3 deletions commands/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions commands/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
30 changes: 22 additions & 8 deletions spec/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
24 changes: 10 additions & 14 deletions spec/ui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3489bb0

Please sign in to comment.