Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds user_keys method

  • Loading branch information...
commit f7ab534e613c9ca1a2ba4baeb22721884ac6a512 1 parent 75a7a2f
@pengwynn pengwynn authored
Showing with 24 additions and 0 deletions.
  1. +13 −0 lib/octokit/client/users.rb
  2. +11 −0 spec/octokit/client/users_spec.rb
View
13 lib/octokit/client/users.rb
@@ -236,6 +236,19 @@ def keys(options={})
get("user/keys", options)
end
+ # Get list of public keys for user.
+ #
+ # Requires authenticated client.
+ #
+ # @return [Array<Hashie::Mash>] Array of hashes representing public keys.
+ # @see Octokit::Client
+ # @see http://developer.github.com/v3/users/keys/#list-public-keys-for-a-user
+ # @example
+ # @client.user_keys('pengwynn'
+ def user_keys(user, options={})
+ get("users/#{user}/keys", options)
+ end
+
# Add public key to user account.
#
# Requires authenticated client.
View
11 spec/octokit/client/users_spec.rb
@@ -299,6 +299,17 @@
end
end
+
+ describe ".user_keys" do
+
+ it "returns public keys for a user" do
+ stub_get("https://api.github.com/users/pengwynn/keys").
+ to_return(json_response("public_keys.json"))
+ public_keys = @client.user_keys 'pengwynn'
+ expect(public_keys.first.id).to eq(103205)
+ end
+
+ end
describe ".add_key" do
Please sign in to comment.
Something went wrong with that request. Please try again.