Permalink
Browse files

add specs for new org api functions.

  • Loading branch information...
1 parent 3883718 commit c8f18a0f0c6790c3ee7f04c74f557fdc69faa8a0 John Ledbetter committed Jan 18, 2012
Showing with 56 additions and 0 deletions.
  1. +21 −0 spec/org_spec.rb
  2. +35 −0 spec/orgs_api_spec.rb
View
@@ -44,4 +44,25 @@
org.repos.should == [:repo1, :repo2]
end
end
+
+ describe '#members'do
+ it 'returns an array of User objects who are members of this org' do
+ api = mock(GitHubV3API::OrgsAPI)
+ api.should_receive(:list_members).with('github').and_return([:user1, :user2])
+
+ org = GitHubV3API::Org.new_with_all_data(api, 'login' => 'github')
+ org.members.should == [:user1, :user2]
+ end
+ end
+
+ describe '#public_members'do
+ it 'returns an array of User objects who are public members of this org' do
+ api = mock(GitHubV3API::OrgsAPI)
+ api.should_receive(:list_public_members).with('github').and_return([:user1, :user2])
+
+ org = GitHubV3API::Org.new_with_all_data(api, 'login' => 'github')
+ org.public_members.should == [:user1, :user2]
+ end
+ end
+
end
View
@@ -39,4 +39,39 @@
api.list_repos('github').should == [:repo1, :repo2]
end
end
+
+ describe '#list_members' do
+ it 'returns the list of members for the specified org' do
+ connection = mock(GitHubV3API, :users => :users_api)
+ connection.should_receive(:get).once.with('/orgs/github/members') \
+ .and_return([:user_hash1, :user_hash2])
+
+ GitHubV3API::User.should_receive(:new).with(:users_api, :user_hash1) \
+ .and_return(:user1)
+
+ GitHubV3API::User.should_receive(:new).with(:users_api, :user_hash2) \
+ .and_return(:user2)
+
+ api = GitHubV3API::OrgsAPI.new(connection)
+ api.list_members('github').should == [:user1, :user2]
+ end
+ end
+
+ describe '#list_public_members' do
+ it 'returns the list of public members for the specified org' do
+ connection = mock(GitHubV3API, :users => :users_api)
+ connection.should_receive(:get).once.with('/orgs/github/public_members') \
+ .and_return([:user_hash1, :user_hash2])
+
+ GitHubV3API::User.should_receive(:new).with(:users_api, :user_hash1) \
+ .and_return(:user1)
+
+ GitHubV3API::User.should_receive(:new).with(:users_api, :user_hash2) \
+ .and_return(:user2)
+
+ api = GitHubV3API::OrgsAPI.new(connection)
+ api.list_public_members('github').should == [:user1, :user2]
+ end
+ end
+
end

0 comments on commit c8f18a0

Please sign in to comment.