Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Making sure more than one person can be added
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Quaranto <nick@quaran.to>
  • Loading branch information
coreyhaines authored and qrush committed Jul 13, 2009
1 parent 761262d commit 3e8df3f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 23 deletions.
20 changes: 14 additions & 6 deletions features/manage_collaborators.feature
Expand Up @@ -3,17 +3,25 @@ Feature: Manage collaborators
Given an account "thoughtbot" with an api key of "deadbeef"

Scenario: Adding a single collaborator for a specific project
Given the following collaborators for "shoulda"
|name |
|thoughtbot|
Given I am adding "rmmt" as a collaborator to "shoulda"
When I execute the following code
"""
Enforcer "thoughtbot", "deadbeef" do
project "shoulda" do
collaborators 'rmmt'
end
end
"""
When I execute it
Then the GitHub API should have received a request to add a "rmmt" as a collaborator for "shoulda"
Then the GitHub API should have received a request to add a "rmmt" as a collaborator for "shoulda"

Scenario: Adding more than one collaborators for a specific project
When I execute the following code
"""
Enforcer "thoughtbot", "deadbeef" do
project "shoulda" do
collaborators 'rmmt', 'coreyhaines', 'qrush'
end
end
"""
Then the GitHub API should have received a request to add a "rmmt" as a collaborator for "shoulda"
And the GitHub API should have received a request to add a "coreyhaines" as a collaborator for "shoulda"
And the GitHub API should have received a request to add a "qrush" as a collaborator for "shoulda"
32 changes: 16 additions & 16 deletions features/step_definitions/enforcer_steps.rb
@@ -1,27 +1,27 @@
Before do
stub(GitHubApi).add_collaborator(anything, anything, anything, anything)
end


Given /^an account "(.*)" with an api key of "(.*)"$/ do |account, api_key|
@account = account
@api_key = api_key
end

Given /^I am adding "(.*)" as a collaborator to "(.*)"$/ do |user, repo, code|
@names << user
@names_list = @names.join('", "')
@collaborators = '{"collaborators: + ["' + @names_list + '"]}'
# Given /^I am adding "(.*)" as a collaborator to "(.*)"$/ do |user, repo, code|
# @names = []
# @names << user
# @names_list = @names.join('", "')
# @collaborators = '{"collaborators: + ["' + @names_list + '"]}'
#
# mock(GitHubApi).add_collaborator(@account, @api_key, repo, user)
# @code = code
# end

mock(GitHubApi).add_collaborator(@account, @api_key, repo, user)
@code = code
When /^I execute the following code$/ do |code|
eval(code)
end

When /^I execute it$/ do
eval(@code)
end

Given /^the following collaborators for "([^\"]*)"$/ do |project_name, table|
@names = []
table.hashes.each do |collaborator|
@names << collaborator[:name]
end
end

Then /^the GitHub API should have received a request to add a "(.*)" as a collaborator for "(.*)"$/ do |user, repo|
assert_received(GitHubApi) { |subject| subject.add_collaborator(@account, @api_key, repo, user) }
Expand Down
13 changes: 13 additions & 0 deletions features/support/env.rb
Expand Up @@ -8,3 +8,16 @@

World(Test::Unit::Assertions)
World(RR::Adapters::TestUnit)

Before do
RR.reset
end

After do
begin
RR.verify
ensure
RR.reset
end
end

13 changes: 12 additions & 1 deletion test/enforcer_test.rb
Expand Up @@ -9,7 +9,7 @@ class EnforcerTest < Test::Unit::TestCase
@enforcer = Enforcer.new(@username, @api_key)
end

should "add collaborators to the project" do
should "add a collaborator to the project" do
@enforcer.project 'foo' do
collaborators 'chaines'
end
Expand All @@ -18,6 +18,17 @@ class EnforcerTest < Test::Unit::TestCase
subject.add_collaborator(@username, @api_key, 'foo', 'chaines')
end
end

should "add collaborators to the project" do
@enforcer.project 'foo' do
collaborators 'chaines', 'qrush'
end

assert_received(GitHubApi) do |subject|
subject.add_collaborator(@username, @api_key, 'foo', 'chaines')
subject.add_collaborator(@username, @api_key, 'foo', 'qrush')
end
end
end

context "setting up enforcer dsl" do
Expand Down

0 comments on commit 3e8df3f

Please sign in to comment.