Permalink
Browse files

Merge branch 'credential-params' of https://github.com/weilu/gist

  • Loading branch information...
2 parents aa42c12 + 69969e8 commit 2835008a651ef35f0d9be687710a91719b6196f0 @ConradIrwin committed May 23, 2013
Showing with 14 additions and 3 deletions.
  1. +3 −3 lib/gist.rb
  2. +11 −0 spec/ghe_spec.rb
View
6 lib/gist.rb
@@ -138,12 +138,12 @@ def shorten(url)
#
# @raise [Gist::Error] if something went wrong
# @see http://developer.github.com/v3/oauth/
- def login!
+ def login! credentials={}
puts "Obtaining OAuth2 access_token from github."
print "GitHub username: "
- username = $stdin.gets.strip
+ username = credentials[:username] || $stdin.gets.strip
print "GitHub password: "
- password = begin
+ password = credentials[:password] || begin
`stty -echo` rescue nil
$stdin.gets.strip
ensure
View
11 spec/ghe_spec.rb
@@ -58,6 +58,17 @@
assert_requested(:post, /#{MOCK_AUTHZ_GHE_URL}authorizations/)
end
+
+ context "when credentials are passed in" do
+
+ it "uses them" do
+ $stdin = StringIO.new "#{MOCK_USER}_wrong\n#{MOCK_PASSWORD}_wrong\n"
+ Gist.login! username: MOCK_USER, password: MOCK_PASSWORD
+
+ assert_requested(:post, /#{MOCK_AUTHZ_GITHUB_URL}authorizations/)
+ end
+
+ end
end
describe :gist do

0 comments on commit 2835008

Please sign in to comment.