lita-github 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,25 +21,40 @@ describe LitaGithub::General do
21
21
 
22
22
  describe '.opts_parse' do
23
23
  it 'should find the valid options' do
24
- o = ' private:true team:heckman bacon:always bacon:sometimes'
24
+ o = %q( private:true team:heckman Bacon:always bacon:sometimes string1:"something here" string2:'something else')
25
25
  co = opts_parse(o)
26
26
  expect(co).to be_an_instance_of Hash
27
- expect(co[:private]).to eql 'true'
28
- expect(co[:team]).to eql 'heckman'
27
+ expect(co.key?(:Bacon)).to be_falsey
28
+ expect(co.key?(:bacon)).to be_truthy
29
29
  expect(co[:bacon]).to eql 'always' # of course it's always
30
- end
31
- end
32
-
33
- describe '.e_opts_parse' do
34
- it 'should find the valid options' do
35
- o = %q( private:true team:heckman bacon:always bacon:sometimes string1:"something here" string2:'something else')
36
- co = e_opts_parse(o)
37
- expect(co).to be_an_instance_of Hash
30
+ expect(co[:bacon]).to_not eql 'sometimes'
38
31
  expect(co[:private]).to eql 'true'
39
32
  expect(co[:team]).to eql 'heckman'
40
- expect(co[:bacon]).to eql 'always' # of course it's always
41
33
  expect(co[:string1]).to eql 'something here'
42
34
  expect(co[:string2]).to eql 'something else'
43
35
  end
44
36
  end
37
+
38
+ describe '.to_i_if_numeric' do
39
+ context 'when value is a number' do
40
+ subject { to_i_if_numeric('42') }
41
+ it { should eql 42 }
42
+ end
43
+
44
+ context 'when value is not a number' do
45
+ let(:val) { 'hello' }
46
+ subject { to_i_if_numeric(val) }
47
+ it { should eql val }
48
+ end
49
+ end
50
+
51
+ describe '.symbolize_opt_key' do
52
+ it 'should return an Array with the downcased/symblized key' do
53
+ kv = %w(Hello! ohai)
54
+ a = symbolize_opt_key(*kv)
55
+ expect(a).to be_an_instance_of Array
56
+ expect(a[0]).to eql kv[0].downcase.to_sym
57
+ expect(a[1]).to eql kv[1]
58
+ end
59
+ end
45
60
  end
@@ -44,50 +44,6 @@ describe LitaGithub::R do
44
44
  describe '::OPT_REGEX' do
45
45
  subject { LitaGithub::R::OPT_REGEX }
46
46
 
47
- context 'it should match' do
48
- it 'test:pass' do
49
- s = ' test:pass'
50
- m = s.scan(subject).flatten.map(&:strip)
51
- expect(m).to eql ['test:pass']
52
- end
53
-
54
- it 'test7_pass:pAss_test' do
55
- s = ' test7_pass:pAss_test'
56
- m = s.scan(subject).flatten.map(&:strip)
57
- expect(m).to eql ['test7_pass:pAss_test']
58
- end
59
-
60
- it 'test:pass bacon:always test:coverage' do
61
- s = ' test:pass bacon:always test:coverage'
62
- m = s.scan(subject).flatten.map(&:strip)
63
- expect(m).to eql ['test:pass', 'bacon:always', 'test:coverage']
64
- end
65
- end
66
-
67
- context 'it should not match' do
68
- it 'test-stuff:fail' do
69
- s = ' test-stuff:fail'
70
- m = s.scan(subject).flatten
71
- expect(m).to be_empty
72
- end
73
-
74
- it 'test: fail' do
75
- s = ' test: fail'
76
- m = s.scan(subject).flatten
77
- expect(m).to be_empty
78
- end
79
-
80
- it 'test:fail (no leading space)' do
81
- s = 'test:fail'
82
- m = s.scan(subject).flatten
83
- expect(m).to be_empty
84
- end
85
- end
86
- end
87
-
88
- describe '::E_OPT_REGEX' do
89
- subject { LitaGithub::R::E_OPT_REGEX }
90
-
91
47
  context 'it should match' do
92
48
  it 'test:pass' do
93
49
  s = ' test:pass'
@@ -18,23 +18,23 @@ describe LitaGithub do
18
18
  describe '::VERSION' do
19
19
  subject { LitaGithub::VERSION }
20
20
  it { should be_an_instance_of String }
21
- it { should match(/\d+\.\d+\.\d+(?:\-[a-zA-Z0-9_\.\-])?/) }
21
+ it { should match(/\d+\.\d+\.\d+(?:\-[a-zA-Z0-9_\.\-]+)?/) }
22
22
  end
23
23
 
24
- describe '::MAJ' do
25
- subject { LitaGithub::MAJ }
24
+ describe '::MAJOR_VERSION' do
25
+ subject { LitaGithub::MAJOR_VERSION }
26
26
  it { should be_an_instance_of Fixnum }
27
27
  it { should be >= 0 }
28
28
  end
29
29
 
30
- describe '::MIN' do
31
- subject { LitaGithub::MIN }
30
+ describe '::MINOR_VERSION' do
31
+ subject { LitaGithub::MINOR_VERSION }
32
32
  it { should be_an_instance_of Fixnum }
33
33
  it { should be >= 0 }
34
34
  end
35
35
 
36
- describe '::REV' do
37
- subject { LitaGithub::REV }
36
+ describe '::REVISION' do
37
+ subject { LitaGithub::REVISION }
38
38
  it { should be_an_instance_of Fixnum }
39
39
  it { should be >= 0 }
40
40
  end
@@ -0,0 +1,162 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ # Copyright 2014 PagerDuty, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'spec_helper'
18
+
19
+ describe Lita::Handlers::GithubIssues, lita_handler: true do
20
+ # issues_list command routing
21
+ it { routes_command('gh issues GrapeDuty/lita-test').to(:issues_list) }
22
+ it { routes_command('gh issues lita-test').to(:issues_list) }
23
+ it { routes_command('gh issues lita-test key:value keys:"values"').to(:issues_list) }
24
+ it { routes_command('gh repo issues GrapeDuty/lita-test').to(:issues_list) }
25
+ it { routes_command('gh repo issues lita-test').to(:issues_list) }
26
+ it { routes_command('gh repo issues lita-test key:value keys:"values"').to(:issues_list) }
27
+
28
+ let(:gh_org) { 'GapeDuty' }
29
+ let(:gh_repo) { 'lita-test' }
30
+ let(:github_issues) { Lita::Handlers::GithubIssues.new('robot') }
31
+
32
+ describe '.validate_list_opts' do
33
+ let(:good_opts) { { state: 'open', sort: 'updated', direction: 'asc' } }
34
+ let(:bad_opts) { Hash.new('sometestval').merge(state: 'shipped', sort: 'most code', direction: 'backwards, yo') }
35
+ let(:bad_state) { good_opts.merge(state: 'something') }
36
+ let(:bad_sort) { good_opts.merge(sort: 'something') }
37
+ let(:bad_direction) { good_opts.merge(direction: 'backwards, yo') }
38
+ let(:io_header) { "Invalid option(s):\n" }
39
+
40
+ context 'when all options are good' do
41
+ it 'should reply with a string' do
42
+ expect(github_issues.send(:validate_list_opts, good_opts)).to be_an_instance_of String
43
+ end
44
+
45
+ it 'should reply with empty string' do
46
+ expect(github_issues.send(:validate_list_opts, good_opts)).to be_empty
47
+ end
48
+ end
49
+
50
+ context 'when :state is invalid' do
51
+ it 'should return a string containing a valid error message' do
52
+ r = github_issues.send(:validate_list_opts, bad_state)
53
+ expect(r).to eql "#{io_header}Issues can be one of the following states: 'open', 'closed', or 'all'\n"
54
+ end
55
+ end
56
+
57
+ context 'when :sort is invalid' do
58
+ it 'should return a string containing a valid error message' do
59
+ r = github_issues.send(:validate_list_opts, bad_sort)
60
+ expect(r).to eql "#{io_header}Issues can be sorted by one of the following: 'created', 'updated', 'comments'\n"
61
+ end
62
+ end
63
+
64
+ context 'when :direction is invalid' do
65
+ it 'should return a string containing a valid error message' do
66
+ r = github_issues.send(:validate_list_opts, bad_direction)
67
+ expect(r).to eql "#{io_header}Issues can be ordered either 'asc' (ascending) or 'desc' (descending)\n"
68
+ end
69
+ end
70
+
71
+ context 'when the user did EVERYTHING wrong' do
72
+ it 'should return a string containing all the error messages' do
73
+ r = github_issues.send(:validate_list_opts, bad_opts)
74
+ expect(r).to eql(
75
+ "#{io_header}Issues can be one of the following states: 'open', 'closed', or 'all'\n" \
76
+ "Issues can be sorted by one of the following: 'created', 'updated', 'comments'\n" \
77
+ "Issues can be ordered either 'asc' (ascending) or 'desc' (descending)\n"
78
+ )
79
+ end
80
+ end
81
+ end
82
+
83
+ describe '.issues_list' do
84
+ before do
85
+ issues = [
86
+ {
87
+ number: 42, title: 'XYXYXYXY', html_url: 'https://github.com/GrapeDuty/lita-test/issues/42',
88
+ user: { login: 'theckman' }
89
+ },
90
+ {
91
+ number: 84, title: 'YZYZYZYZ', html_url: 'https://github.com/GrapeDuty/lita-test/issues/84',
92
+ user: { login: 'theckman' }
93
+ },
94
+ {
95
+ number: 99, title: 'NO', html_url: 'https://github.com/GrapeDuty/lita-test/issues/99',
96
+ user: { login: 'theckman' }, pull_request: {}
97
+ }
98
+ ]
99
+ @octo_obj = double('Octokit::Client', list_issues: issues)
100
+ allow(github_issues).to receive(:octo).and_return(@octo_obj)
101
+ allow(github_issues).to receive(:repo?).and_return(true)
102
+ allow(github_issues).to receive(:validate_list_opts).and_return('')
103
+ end
104
+
105
+ context 'when all goes well' do
106
+ it 'should reply with the list of issues' do
107
+ send_command('gh issues GrapeDuty/lita-test')
108
+ r = replies.last
109
+ expect(r).to eql "Showing 2 issue(s) for GrapeDuty/lita-test
110
+ GrapeDuty/lita-test #42: 'XYXYXYXY' opened by theckman :: https://github.com/GrapeDuty/lita-test/issues/42
111
+ GrapeDuty/lita-test #84: 'YZYZYZYZ' opened by theckman :: https://github.com/GrapeDuty/lita-test/issues/84
112
+ "
113
+ end
114
+ end
115
+
116
+ context 'when there are no issues' do
117
+ before { allow(@octo_obj).to receive(:list_issues).and_return([]) }
118
+
119
+ it 'should return message indicating no issues' do
120
+ send_command('gh issues GrapeDuty/lita-test')
121
+ expect(replies.last).to eql 'There are no open issues for GrapeDuty/lita-test'
122
+ end
123
+ end
124
+
125
+ context 'when there is an option that fails validation' do
126
+ before { allow(github_issues).to receive(:validate_list_opts).and_return('sadpanda') }
127
+
128
+ it 'should reply with the response from .validate_list_opts' do
129
+ send_command('gh issues GrapeDuty/lita-test')
130
+ expect(replies.last).to eql 'sadpanda'
131
+ end
132
+ end
133
+
134
+ context 'when the repo is not found' do
135
+ before { allow(github_issues).to receive(:repo?).and_return(false) }
136
+
137
+ it 'should reply with response indicating repo not found' do
138
+ send_command('gh issues GrapeDuty/lita-test')
139
+ expect(replies.last).to eql 'That repo (GrapeDuty/lita-test) was not found'
140
+ end
141
+ end
142
+
143
+ context 'when an option passes validation, but fails from GitHub' do
144
+ before { allow(@octo_obj).to receive(:list_issues).and_raise(Octokit::UnprocessableEntity.new) }
145
+
146
+ it 'should reply indicating an issue was hit and include the exception message' do
147
+ send_command('gh issues GrapeDuty/lita-test')
148
+ expect(replies.last).to eql "An invalid option was provided, here's the error from Octokit:
149
+ Octokit::UnprocessableEntity"
150
+ end
151
+ end
152
+
153
+ context 'when there is a general error when calling GitHub' do
154
+ before { allow(@octo_obj).to receive(:list_issues).and_raise(StandardError.new) }
155
+
156
+ it 'should reply indicating an issue was hit and include the exception message' do
157
+ send_command('gh issues GrapeDuty/lita-test')
158
+ expect(replies.last).to eql 'I had a problem :( ... StandardError'
159
+ end
160
+ end
161
+ end
162
+ end
@@ -29,7 +29,30 @@ describe Lita::Handlers::GithubOrg, lita_handler: true do
29
29
  it { routes_command('gh org team add GrapeDuty name:"All Staff" perms:pull').to(:org_team_add) }
30
30
  it { routes_command('gh org team add name:"All Staff" perms:pull').to(:org_team_add) }
31
31
 
32
+ # org_team_rm routing
33
+ it { routes_command('gh org team rm GrapeDuty ops').to(:org_team_rm) }
34
+ it { routes_command('gh org team rm GrapeDuty 42').to(:org_team_rm) }
35
+ it { routes_command('gh org team rm ops').to(:org_team_rm) }
36
+ it { routes_command('gh org team rm 42').to(:org_team_rm) }
37
+
38
+ # org_user_add routing
39
+ it { routes_command('gh org user add GrapeDuty heckmantest theckman').to(:org_user_add) }
40
+ it { routes_command('gh org user add heckmantest theckman').to(:org_user_add) }
41
+ it { routes_command('gh org user add GrapeDuty 42 theckman').to(:org_user_add) }
42
+ it { routes_command('gh org user add 42 theckman').to(:org_user_add) }
43
+
44
+ # org_user_rm routing
45
+ it { routes_command('gh org user rm GrapeDuty heckmantest theckman').to(:org_user_rm) }
46
+ it { routes_command('gh org user rm heckmantest theckman').to(:org_user_rm) }
47
+ it { routes_command('gh org user rm GrapeDuty 42 theckman').to(:org_user_rm) }
48
+ it { routes_command('gh org user rm 42 theckman').to(:org_user_rm) }
49
+
50
+ # org_eject_user routing
51
+ it { routes_command('gh org eject GrapeDuty theckman').to(:org_eject_user) }
52
+ it { routes_command('gh org eject theckman').to(:org_eject_user) }
53
+
32
54
  let(:github_org) { Lita::Handlers::GithubOrg.new('robot') }
55
+ let(:disabled_err) { 'Sorry, this function has either been disabled or not enabled in the config' }
33
56
 
34
57
  ####
35
58
  # Helper Methods
@@ -165,7 +188,7 @@ Name: HeckmanTest, Slug: heckmantest, ID: 42, Perms: push
165
188
 
166
189
  it 'should return the method disabled error' do
167
190
  send_command('gh org team add GrapeDuty name:"HeckmanTest" perms:pull')
168
- expect(replies.last).to eql 'Sorry, this function has either been disabled or not enabled in the config'
191
+ expect(replies.last).to eql disabled_err
169
192
  end
170
193
  end
171
194
 
@@ -226,7 +249,7 @@ Missing the perms option
226
249
 
227
250
  it 'should return the method disabled error' do
228
251
  send_command('gh org team rm GrapeDuty 42')
229
- expect(replies.last).to eql 'Sorry, this function has either been disabled or not enabled in the config'
252
+ expect(replies.last).to eql disabled_err
230
253
  end
231
254
  end
232
255
 
@@ -249,4 +272,238 @@ Missing the perms option
249
272
  end
250
273
  end
251
274
  end
275
+
276
+ describe '.org_eject_user' do
277
+ before do
278
+ @self_user = {
279
+ name: 'OfficerURL',
280
+ login: 'OfficerURL',
281
+ id: 8_525_060
282
+ }
283
+ @t_user = {
284
+ name: 'Tim Heckman',
285
+ login: 'theckman',
286
+ id: 787_332
287
+ }
288
+ @octo_obj = double('Octokit::Client', remove_organization_member: true)
289
+ @conf_obj = double('Lita::Config', default_org: 'GrapeDuty')
290
+ allow(@octo_obj).to receive(:user).with(no_args).and_return(@self_user)
291
+ allow(@octo_obj).to receive(:user).with('theckman').and_return(@t_user)
292
+ allow(github_org).to receive(:func_disabled?).and_return(false)
293
+ allow(github_org).to receive(:octo).and_return(@octo_obj)
294
+ allow(github_org).to receive(:cofig).and_return(@conf_obj)
295
+ end
296
+
297
+ context 'when all goes well' do
298
+ it 'should reply that the user was ejected' do
299
+ send_command('gh org eject GrapeDuty theckman')
300
+ expect(replies.last).to eql 'Ejected theckman out of GrapeDuty'
301
+ end
302
+ end
303
+
304
+ context 'when the method is disabled' do
305
+ before { allow(github_org).to receive(:func_disabled?).and_return(true) }
306
+
307
+ it 'should return the method disabled error' do
308
+ send_command('gh org eject GrapeDuty theckman')
309
+ expect(replies.last).to eql disabled_err
310
+ end
311
+ end
312
+
313
+ context 'when the user is the same user' do
314
+ before { allow(@octo_obj).to receive(:user).with('OfficerURL').and_return(@self_user) }
315
+
316
+ it 'should return the gtfo error message' do
317
+ send_command('gh org eject GrapeDuty OfficerURL')
318
+ expect(replies.last).to eql "No...\n\nಠ_ಠ"
319
+ end
320
+ end
321
+
322
+ context 'when the user is not found' do
323
+ before { allow(@octo_obj).to receive(:user).with('theckman').and_raise(Octokit::NotFound.new) }
324
+
325
+ it 'should reply with the user not found message' do
326
+ send_command('gh org eject GrapeDuty theckman')
327
+ expect(replies.last).to eql 'Unable to find the GitHub user theckman'
328
+ end
329
+ end
330
+
331
+ context 'when the Octokit client call bombs' do
332
+ before { allow(@octo_obj).to receive(:remove_organization_member).and_raise(Octokit::NotFound.new) }
333
+
334
+ it 'should return the *boom* error' do
335
+ send_command('gh org eject GrapeDuty theckman')
336
+ expect(replies.last).to eql 'I had a problem :( ... Octokit::NotFound'
337
+ end
338
+ end
339
+
340
+ context 'when the action fails' do
341
+ before { allow(@octo_obj).to receive(:remove_organization_member).and_return(false) }
342
+
343
+ it 'should respond with the failure message' do
344
+ send_command('gh org eject GrapeDuty theckman')
345
+ expect(replies.last).to eql 'Failed to eject the user from the organization for an unknown reason'
346
+ end
347
+ end
348
+ end
349
+
350
+ describe '.org_user_add' do
351
+ before do
352
+ @self_user = {
353
+ name: 'OfficerURL',
354
+ login: 'OfficerURL',
355
+ id: 8_525_060
356
+ }
357
+ @t_user = {
358
+ name: 'Tim Heckman',
359
+ login: 'theckman',
360
+ id: 787_332
361
+ }
362
+ @team = {
363
+ name: 'HeckmanTest',
364
+ id: 42,
365
+ slug: 'heckmantest'
366
+ }
367
+ @octo_obj = double('Octokit::Client', team: @team, add_team_membership: true)
368
+ @conf_obj = double('Lita::Config', default_org: 'GrapeDuty')
369
+ allow(@octo_obj).to receive(:user).with(no_args).and_return(@self_user)
370
+ allow(@octo_obj).to receive(:user).with('theckman').and_return(@t_user)
371
+ allow(github_org).to receive(:func_disabled?).and_return(false)
372
+ allow(github_org).to receive(:octo).and_return(@octo_obj)
373
+ allow(github_org).to receive(:cofig).and_return(@conf_obj)
374
+ allow(github_org).to receive(:team_id).and_return(42)
375
+ end
376
+
377
+ context 'when all goes well' do
378
+ it 'should respond with a successful add' do
379
+ send_command('gh org user add GrapeDuty heckmantest theckman')
380
+ expect(replies.last).to eql "theckman has been added to the 'GrapeDuty/HeckmanTest' (heckmantest) team"
381
+ end
382
+ end
383
+
384
+ context 'when the method is disabled' do
385
+ before { allow(github_org).to receive(:func_disabled?).and_return(true) }
386
+
387
+ it 'should return the method disabled error' do
388
+ send_command('gh org user add GrapeDuty heckmantest theckman')
389
+ expect(replies.last).to eql disabled_err
390
+ end
391
+ end
392
+
393
+ context 'when the user is the same user' do
394
+ before { allow(@octo_obj).to receive(:user).with('OfficerURL').and_return(@self_user) }
395
+
396
+ it 'should return the gtfo error message' do
397
+ send_command('gh org user add GrapeDuty heckmantest OfficerURL')
398
+ expect(replies.last).to eql "No...\n\nಠ_ಠ"
399
+ end
400
+ end
401
+
402
+ context 'when the user is not found' do
403
+ before { allow(@octo_obj).to receive(:user).with('theckman').and_raise(Octokit::NotFound.new) }
404
+
405
+ it 'should reply with the user not found message' do
406
+ send_command('gh org user add GrapeDuty heckmantest theckman')
407
+ expect(replies.last).to eql 'Unable to find the GitHub user theckman'
408
+ end
409
+ end
410
+
411
+ context 'when the team is not found' do
412
+ before { allow(@octo_obj).to receive(:team).with(42).and_raise(Octokit::NotFound.new) }
413
+
414
+ it 'should reply with the team not found message' do
415
+ send_command('gh org user add GrapeDuty heckmantest theckman')
416
+ expect(replies.last).to eql 'Unable to match any teams based on: heckmantest'
417
+ end
418
+ end
419
+
420
+ context 'when an error is hit adding the team membership' do
421
+ before { allow(@octo_obj).to receive(:add_team_membership).with(42, 'theckman').and_raise(StandardError.new) }
422
+
423
+ it 'should reply with the *boom* message' do
424
+ send_command('gh org user add GrapeDuty heckmantest theckman')
425
+ expect(replies.last).to eql 'I had a problem :( ... StandardError'
426
+ end
427
+ end
428
+ end
429
+
430
+ describe '.org_user_rm' do
431
+ before do
432
+ @self_user = {
433
+ name: 'OfficerURL',
434
+ login: 'OfficerURL',
435
+ id: 8_525_060
436
+ }
437
+ @t_user = {
438
+ name: 'Tim Heckman',
439
+ login: 'theckman',
440
+ id: 787_332
441
+ }
442
+ @team = {
443
+ name: 'HeckmanTest',
444
+ id: 42,
445
+ slug: 'heckmantest'
446
+ }
447
+ @octo_obj = double('Octokit::Client', team: @team, remove_team_member: true)
448
+ @conf_obj = double('Lita::Config', default_org: 'GrapeDuty')
449
+ allow(@octo_obj).to receive(:user).with(no_args).and_return(@self_user)
450
+ allow(@octo_obj).to receive(:user).with('theckman').and_return(@t_user)
451
+ allow(github_org).to receive(:func_disabled?).and_return(false)
452
+ allow(github_org).to receive(:octo).and_return(@octo_obj)
453
+ allow(github_org).to receive(:cofig).and_return(@conf_obj)
454
+ allow(github_org).to receive(:team_id).and_return(42)
455
+ end
456
+
457
+ context 'when all goes well' do
458
+ it 'should respond with a successful removal' do
459
+ send_command('gh org user rm GrapeDuty heckmantest theckman')
460
+ expect(replies.last).to eql "theckman has been removed from the 'GrapeDuty/HeckmanTest' (heckmantest) team"
461
+ end
462
+ end
463
+
464
+ context 'when the method is disabled' do
465
+ before { allow(github_org).to receive(:func_disabled?).and_return(true) }
466
+
467
+ it 'should return the method disabled error' do
468
+ send_command('gh org user rm GrapeDuty heckmantest theckman')
469
+ expect(replies.last).to eql disabled_err
470
+ end
471
+ end
472
+
473
+ context 'when the user is the same user' do
474
+ before { allow(@octo_obj).to receive(:user).with('OfficerURL').and_return(@self_user) }
475
+
476
+ it 'should return the gtfo error message' do
477
+ send_command('gh org user rm GrapeDuty heckmantest OfficerURL')
478
+ expect(replies.last).to eql "No...\n\nಠ_ಠ"
479
+ end
480
+ end
481
+
482
+ context 'when the user is not found' do
483
+ before { allow(@octo_obj).to receive(:user).with('theckman').and_raise(Octokit::NotFound.new) }
484
+
485
+ it 'should reply with the user not found message' do
486
+ send_command('gh org user rm GrapeDuty heckmantest theckman')
487
+ expect(replies.last).to eql 'Unable to find the GitHub user theckman'
488
+ end
489
+ end
490
+
491
+ context 'when the team is not found' do
492
+ before { allow(@octo_obj).to receive(:team).with(42).and_raise(Octokit::NotFound.new) }
493
+
494
+ it 'should reply with the team not found message' do
495
+ send_command('gh org user rm GrapeDuty heckmantest theckman')
496
+ expect(replies.last).to eql 'Unable to match any teams based on: heckmantest'
497
+ end
498
+ end
499
+
500
+ context 'when an error is hit adding the team membership' do
501
+ before { allow(@octo_obj).to receive(:remove_team_member).with(42, 'theckman').and_raise(StandardError.new) }
502
+
503
+ it 'should reply with the *boom* message' do
504
+ send_command('gh org user rm GrapeDuty heckmantest theckman')
505
+ expect(replies.last).to eql 'I had a problem :( ... StandardError'
506
+ end
507
+ end
508
+ end
252
509
  end