Navigation Menu

Skip to content

Commit

Permalink
add specs for new org api functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ledbetter committed Jan 18, 2012
1 parent 3883718 commit c8f18a0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/org_spec.rb
Expand Up @@ -44,4 +44,25 @@
org.repos.should == [:repo1, :repo2] org.repos.should == [:repo1, :repo2]
end end
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 end
35 changes: 35 additions & 0 deletions spec/orgs_api_spec.rb
Expand Up @@ -39,4 +39,39 @@
api.list_repos('github').should == [:repo1, :repo2] api.list_repos('github').should == [:repo1, :repo2]
end end
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 end

0 comments on commit c8f18a0

Please sign in to comment.