Skip to content
Browse files

Die if a github API token cannot be found

  • Loading branch information...
1 parent a4636a5 commit 42c45f2ec2a739e8ffa22bb31f50eb8ffceb362b @keithpitt keithpitt committed Jan 13, 2011
Showing with 13 additions and 1 deletion.
  1. +6 −1 lib/github/command.rb
  2. +7 −0 spec/command_spec.rb
View
7 lib/github/command.rb
@@ -71,7 +71,12 @@ def github_user
end
def github_token
- git("config --get github.token")
+ token = git("config --get github.token")
+ if token.empty?
+ die("You must 'git config github.token [your API token]' before running this command")
+ end
+
+ token
end
def shell_user
View
7 spec/command_spec.rb
@@ -79,4 +79,11 @@
@command.should_receive(:exit!).once
@command.die "message"
end
+
+ it "should die if a github API token cannot be found" do
+ @command.should_receive(:git).once.with("config --get github.token").and_return("")
+ @command.should_receive(:puts).once.with("=> You must 'git config github.token [your API token]' before running this command")
+ @command.should_receive(:exit!).once
+ @command.github_token
+ end
end

0 comments on commit 42c45f2

Please sign in to comment.
Something went wrong with that request. Please try again.