brat 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +24 -0
  6. data/README.md +103 -0
  7. data/Rakefile +9 -0
  8. data/bin/brat +7 -0
  9. data/brat.gemspec +26 -0
  10. data/lib/brat.rb +37 -0
  11. data/lib/brat/api.rb +17 -0
  12. data/lib/brat/cli.rb +47 -0
  13. data/lib/brat/cli_helpers.rb +175 -0
  14. data/lib/brat/client.rb +18 -0
  15. data/lib/brat/client/branches.rb +79 -0
  16. data/lib/brat/client/groups.rb +88 -0
  17. data/lib/brat/client/issues.rb +92 -0
  18. data/lib/brat/client/merge_requests.rb +107 -0
  19. data/lib/brat/client/milestones.rb +57 -0
  20. data/lib/brat/client/notes.rb +106 -0
  21. data/lib/brat/client/projects.rb +298 -0
  22. data/lib/brat/client/repositories.rb +78 -0
  23. data/lib/brat/client/snippets.rb +86 -0
  24. data/lib/brat/client/system_hooks.rb +58 -0
  25. data/lib/brat/client/users.rb +123 -0
  26. data/lib/brat/configuration.rb +40 -0
  27. data/lib/brat/error.rb +42 -0
  28. data/lib/brat/help.rb +44 -0
  29. data/lib/brat/objectified_hash.rb +24 -0
  30. data/lib/brat/request.rb +101 -0
  31. data/lib/brat/shell.rb +49 -0
  32. data/lib/brat/version.rb +3 -0
  33. data/spec/brat/cli_spec.rb +80 -0
  34. data/spec/brat/client/branches_spec.rb +103 -0
  35. data/spec/brat/client/groups_spec.rb +111 -0
  36. data/spec/brat/client/issues_spec.rb +122 -0
  37. data/spec/brat/client/merge_requests_spec.rb +124 -0
  38. data/spec/brat/client/milestones_spec.rb +66 -0
  39. data/spec/brat/client/notes_spec.rb +156 -0
  40. data/spec/brat/client/projects_spec.rb +357 -0
  41. data/spec/brat/client/repositories_spec.rb +92 -0
  42. data/spec/brat/client/snippets_spec.rb +85 -0
  43. data/spec/brat/client/system_hooks_spec.rb +69 -0
  44. data/spec/brat/client/users_spec.rb +192 -0
  45. data/spec/brat/objectified_hash_spec.rb +23 -0
  46. data/spec/brat/request_spec.rb +48 -0
  47. data/spec/brat_spec.rb +65 -0
  48. data/spec/fixtures/branch.json +1 -0
  49. data/spec/fixtures/branches.json +1 -0
  50. data/spec/fixtures/comment_merge_request.json +1 -0
  51. data/spec/fixtures/create_branch.json +1 -0
  52. data/spec/fixtures/create_merge_request.json +1 -0
  53. data/spec/fixtures/error_already_exists.json +1 -0
  54. data/spec/fixtures/group.json +60 -0
  55. data/spec/fixtures/group_create.json +1 -0
  56. data/spec/fixtures/group_member.json +1 -0
  57. data/spec/fixtures/group_member_delete.json +1 -0
  58. data/spec/fixtures/group_members.json +1 -0
  59. data/spec/fixtures/groups.json +2 -0
  60. data/spec/fixtures/issue.json +1 -0
  61. data/spec/fixtures/issues.json +1 -0
  62. data/spec/fixtures/key.json +1 -0
  63. data/spec/fixtures/keys.json +1 -0
  64. data/spec/fixtures/merge_request.json +1 -0
  65. data/spec/fixtures/merge_request_comments.json +1 -0
  66. data/spec/fixtures/merge_requests.json +1 -0
  67. data/spec/fixtures/milestone.json +1 -0
  68. data/spec/fixtures/milestones.json +1 -0
  69. data/spec/fixtures/note.json +1 -0
  70. data/spec/fixtures/notes.json +1 -0
  71. data/spec/fixtures/project.json +1 -0
  72. data/spec/fixtures/project_commit.json +13 -0
  73. data/spec/fixtures/project_commit_diff.json +10 -0
  74. data/spec/fixtures/project_commits.json +1 -0
  75. data/spec/fixtures/project_delete_key.json +8 -0
  76. data/spec/fixtures/project_events.json +1 -0
  77. data/spec/fixtures/project_for_user.json +1 -0
  78. data/spec/fixtures/project_fork_link.json +1 -0
  79. data/spec/fixtures/project_hook.json +1 -0
  80. data/spec/fixtures/project_hooks.json +1 -0
  81. data/spec/fixtures/project_issues.json +1 -0
  82. data/spec/fixtures/project_key.json +6 -0
  83. data/spec/fixtures/project_keys.json +6 -0
  84. data/spec/fixtures/project_tags.json +1 -0
  85. data/spec/fixtures/projects.json +1 -0
  86. data/spec/fixtures/protect_branch.json +1 -0
  87. data/spec/fixtures/session.json +1 -0
  88. data/spec/fixtures/snippet.json +1 -0
  89. data/spec/fixtures/snippets.json +1 -0
  90. data/spec/fixtures/system_hook.json +1 -0
  91. data/spec/fixtures/system_hook_test.json +1 -0
  92. data/spec/fixtures/system_hooks.json +1 -0
  93. data/spec/fixtures/tag.json +1 -0
  94. data/spec/fixtures/team_member.json +1 -0
  95. data/spec/fixtures/team_members.json +1 -0
  96. data/spec/fixtures/unprotect_branch.json +1 -0
  97. data/spec/fixtures/update_merge_request.json +1 -0
  98. data/spec/fixtures/user.json +1 -0
  99. data/spec/fixtures/users.json +1 -0
  100. data/spec/spec_helper.rb +74 -0
  101. metadata +281 -0
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brat::Client do
4
+ describe ".milestones" do
5
+ before do
6
+ stub_get("/projects/3/milestones", "milestones")
7
+ @milestones = Brat.milestones(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects/3/milestones")).to have_been_made
12
+ end
13
+
14
+ it "should return an array of project's milestones" do
15
+ expect(@milestones).to be_an Array
16
+ expect(@milestones.first.project_id).to eq(3)
17
+ end
18
+ end
19
+
20
+ describe ".milestone" do
21
+ before do
22
+ stub_get("/projects/3/milestones/1", "milestone")
23
+ @milestone = Brat.milestone(3, 1)
24
+ end
25
+
26
+ it "should get the correct resource" do
27
+ expect(a_get("/projects/3/milestones/1")).to have_been_made
28
+ end
29
+
30
+ it "should return information about a milestone" do
31
+ expect(@milestone.project_id).to eq(3)
32
+ end
33
+ end
34
+
35
+ describe ".create_milestone" do
36
+ before do
37
+ stub_post("/projects/3/milestones", "milestone")
38
+ @milestone = Brat.create_milestone(3, 'title')
39
+ end
40
+
41
+ it "should get the correct resource" do
42
+ expect(a_post("/projects/3/milestones").
43
+ with(:body => {:title => 'title'})).to have_been_made
44
+ end
45
+
46
+ it "should return information about a created milestone" do
47
+ expect(@milestone.project_id).to eq(3)
48
+ end
49
+ end
50
+
51
+ describe ".edit_milestone" do
52
+ before do
53
+ stub_put("/projects/3/milestones/33", "milestone")
54
+ @milestone = Brat.edit_milestone(3, 33, :title => 'title')
55
+ end
56
+
57
+ it "should get the correct resource" do
58
+ expect(a_put("/projects/3/milestones/33").
59
+ with(:body => {:title => 'title'})).to have_been_made
60
+ end
61
+
62
+ it "should return information about an edited milestone" do
63
+ expect(@milestone.project_id).to eq(3)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,156 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brat::Client do
4
+ describe "notes" do
5
+ context "when wall notes" do
6
+ before do
7
+ stub_get("/projects/3/notes", "notes")
8
+ @notes = Brat.notes(3)
9
+ end
10
+
11
+ it "should get the correct resource" do
12
+ expect(a_get("/projects/3/notes")).to have_been_made
13
+ end
14
+
15
+ it "should return an array of notes" do
16
+ expect(@notes).to be_an Array
17
+ expect(@notes.first.author.name).to eq("John Smith")
18
+ end
19
+ end
20
+
21
+ context "when issue notes" do
22
+ before do
23
+ stub_get("/projects/3/issues/7/notes", "notes")
24
+ @notes = Brat.issue_notes(3, 7)
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ expect(a_get("/projects/3/issues/7/notes")).to have_been_made
29
+ end
30
+
31
+ it "should return an array of notes" do
32
+ expect(@notes).to be_an Array
33
+ expect(@notes.first.author.name).to eq("John Smith")
34
+ end
35
+ end
36
+
37
+ context "when snippet notes" do
38
+ before do
39
+ stub_get("/projects/3/snippets/7/notes", "notes")
40
+ @notes = Brat.snippet_notes(3, 7)
41
+ end
42
+
43
+ it "should get the correct resource" do
44
+ expect(a_get("/projects/3/snippets/7/notes")).to have_been_made
45
+ end
46
+
47
+ it "should return an array of notes" do
48
+ expect(@notes).to be_an Array
49
+ expect(@notes.first.author.name).to eq("John Smith")
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "note" do
55
+ context "when wall note" do
56
+ before do
57
+ stub_get("/projects/3/notes/1201", "note")
58
+ @note = Brat.note(3, 1201)
59
+ end
60
+
61
+ it "should get the correct resource" do
62
+ expect(a_get("/projects/3/notes/1201")).to have_been_made
63
+ end
64
+
65
+ it "should return information about a note" do
66
+ expect(@note.body).to eq("The solution is rather tricky")
67
+ expect(@note.author.name).to eq("John Smith")
68
+ end
69
+ end
70
+
71
+ context "when issue note" do
72
+ before do
73
+ stub_get("/projects/3/issues/7/notes/1201", "note")
74
+ @note = Brat.issue_note(3, 7, 1201)
75
+ end
76
+
77
+ it "should get the correct resource" do
78
+ expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made
79
+ end
80
+
81
+ it "should return information about a note" do
82
+ expect(@note.body).to eq("The solution is rather tricky")
83
+ expect(@note.author.name).to eq("John Smith")
84
+ end
85
+ end
86
+
87
+ context "when snippet note" do
88
+ before do
89
+ stub_get("/projects/3/snippets/7/notes/1201", "note")
90
+ @note = Brat.snippet_note(3, 7, 1201)
91
+ end
92
+
93
+ it "should get the correct resource" do
94
+ expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made
95
+ end
96
+
97
+ it "should return information about a note" do
98
+ expect(@note.body).to eq("The solution is rather tricky")
99
+ expect(@note.author.name).to eq("John Smith")
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "create note" do
105
+ context "when wall note" do
106
+ before do
107
+ stub_post("/projects/3/notes", "note")
108
+ @note = Brat.create_note(3, "The solution is rather tricky")
109
+ end
110
+
111
+ it "should get the correct resource" do
112
+ expect(a_post("/projects/3/notes").
113
+ with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
114
+ end
115
+
116
+ it "should return information about a created note" do
117
+ expect(@note.body).to eq("The solution is rather tricky")
118
+ expect(@note.author.name).to eq("John Smith")
119
+ end
120
+ end
121
+
122
+ context "when issue note" do
123
+ before do
124
+ stub_post("/projects/3/issues/7/notes", "note")
125
+ @note = Brat.create_issue_note(3, 7, "The solution is rather tricky")
126
+ end
127
+
128
+ it "should get the correct resource" do
129
+ expect(a_post("/projects/3/issues/7/notes").
130
+ with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
131
+ end
132
+
133
+ it "should return information about a created note" do
134
+ expect(@note.body).to eq("The solution is rather tricky")
135
+ expect(@note.author.name).to eq("John Smith")
136
+ end
137
+ end
138
+
139
+ context "when snippet note" do
140
+ before do
141
+ stub_post("/projects/3/snippets/7/notes", "note")
142
+ @note = Brat.create_snippet_note(3, 7, "The solution is rather tricky")
143
+ end
144
+
145
+ it "should get the correct resource" do
146
+ expect(a_post("/projects/3/snippets/7/notes").
147
+ with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
148
+ end
149
+
150
+ it "should return information about a created note" do
151
+ expect(@note.body).to eq("The solution is rather tricky")
152
+ expect(@note.author.name).to eq("John Smith")
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,357 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brat::Client do
4
+ describe ".projects" do
5
+ before do
6
+ stub_get("/projects", "projects")
7
+ @projects = Brat.projects
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/projects")).to have_been_made
12
+ end
13
+
14
+ it "should return an array of projects" do
15
+ expect(@projects).to be_an Array
16
+ expect(@projects.first.name).to eq("Brute")
17
+ expect(@projects.first.owner.name).to eq("John Smith")
18
+ end
19
+ end
20
+
21
+ describe ".project" do
22
+ before do
23
+ stub_get("/projects/3", "project")
24
+ @project = Brat.project(3)
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ expect(a_get("/projects/3")).to have_been_made
29
+ end
30
+
31
+ it "should return information about a project" do
32
+ expect(@project.name).to eq("Brat")
33
+ expect(@project.owner.name).to eq("John Smith")
34
+ end
35
+ end
36
+
37
+ describe ".project_events" do
38
+ before do
39
+ stub_get("/projects/2/events", "project_events")
40
+ @events = Brat.project_events(2)
41
+ end
42
+
43
+ it "should get the correct resource" do
44
+ expect(a_get("/projects/2/events")).to have_been_made
45
+ end
46
+
47
+ it "should return an array of events" do
48
+ expect(@events).to be_an Array
49
+ expect(@events.size).to eq(2)
50
+ end
51
+
52
+ it "should return the action name of the event" do
53
+ expect(@events.first.action_name).to eq("opened")
54
+ end
55
+ end
56
+
57
+ describe ".create_project" do
58
+ before do
59
+ stub_post("/projects", "project")
60
+ @project = Brat.create_project('Brat')
61
+ end
62
+
63
+ it "should get the correct resource" do
64
+ expect(a_post("/projects")).to have_been_made
65
+ end
66
+
67
+ it "should return information about a created project" do
68
+ expect(@project.name).to eq("Brat")
69
+ expect(@project.owner.name).to eq("John Smith")
70
+ end
71
+ end
72
+
73
+ describe ".create_project for user" do
74
+ before do
75
+ stub_post("/users", "user")
76
+ @owner = Brat.create_user("john@example.com", "pass", {name: 'John Owner'})
77
+ stub_post("/projects/user/#{@owner.id}", "project_for_user")
78
+ @project = Brat.create_project('Brute', {:user_id => @owner.id})
79
+ end
80
+
81
+ it "should return information about a created project" do
82
+ expect(@project.name).to eq("Brute")
83
+ expect(@project.owner.name).to eq("John Owner")
84
+ end
85
+ end
86
+
87
+ describe ".delete_project" do
88
+ before do
89
+ stub_delete("/projects/Brat", "project")
90
+ @project = Brat.delete_project('Brat')
91
+ end
92
+
93
+ it "should get the correct resource" do
94
+ expect(a_delete("/projects/Brat")).to have_been_made
95
+ end
96
+
97
+ it "should return information about a deleted project" do
98
+ expect(@project.name).to eq("Brat")
99
+ expect(@project.owner.name).to eq("John Smith")
100
+ end
101
+ end
102
+
103
+ describe ".team_members" do
104
+ before do
105
+ stub_get("/projects/3/members", "team_members")
106
+ @team_members = Brat.team_members(3)
107
+ end
108
+
109
+ it "should get the correct resource" do
110
+ expect(a_get("/projects/3/members")).to have_been_made
111
+ end
112
+
113
+ it "should return an array of team members" do
114
+ expect(@team_members).to be_an Array
115
+ expect(@team_members.first.name).to eq("John Smith")
116
+ end
117
+ end
118
+
119
+ describe ".team_member" do
120
+ before do
121
+ stub_get("/projects/3/members/1", "team_member")
122
+ @team_member = Brat.team_member(3, 1)
123
+ end
124
+
125
+ it "should get the correct resource" do
126
+ expect(a_get("/projects/3/members/1")).to have_been_made
127
+ end
128
+
129
+ it "should return information about a team member" do
130
+ expect(@team_member.name).to eq("John Smith")
131
+ end
132
+ end
133
+
134
+ describe ".add_team_member" do
135
+ before do
136
+ stub_post("/projects/3/members", "team_member")
137
+ @team_member = Brat.add_team_member(3, 1, 40)
138
+ end
139
+
140
+ it "should get the correct resource" do
141
+ expect(a_post("/projects/3/members").
142
+ with(:body => {:user_id => '1', :access_level => '40'})).to have_been_made
143
+ end
144
+
145
+ it "should return information about an added team member" do
146
+ expect(@team_member.name).to eq("John Smith")
147
+ end
148
+ end
149
+
150
+ describe ".edit_team_member" do
151
+ before do
152
+ stub_put("/projects/3/members/1", "team_member")
153
+ @team_member = Brat.edit_team_member(3, 1, 40)
154
+ end
155
+
156
+ it "should get the correct resource" do
157
+ expect(a_put("/projects/3/members/1").
158
+ with(:body => {:access_level => '40'})).to have_been_made
159
+ end
160
+
161
+ it "should return information about an edited team member" do
162
+ expect(@team_member.name).to eq("John Smith")
163
+ end
164
+ end
165
+
166
+ describe ".remove_team_member" do
167
+ before do
168
+ stub_delete("/projects/3/members/1", "team_member")
169
+ @team_member = Brat.remove_team_member(3, 1)
170
+ end
171
+
172
+ it "should get the correct resource" do
173
+ expect(a_delete("/projects/3/members/1")).to have_been_made
174
+ end
175
+
176
+ it "should return information about a removed team member" do
177
+ expect(@team_member.name).to eq("John Smith")
178
+ end
179
+ end
180
+
181
+ describe ".project_hooks" do
182
+ before do
183
+ stub_get("/projects/1/hooks", "project_hooks")
184
+ @hooks = Brat.project_hooks(1)
185
+ end
186
+
187
+ it "should get the correct resource" do
188
+ expect(a_get("/projects/1/hooks")).to have_been_made
189
+ end
190
+
191
+ it "should return an array of hooks" do
192
+ expect(@hooks).to be_an Array
193
+ expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci")
194
+ end
195
+ end
196
+
197
+ describe ".project_hook" do
198
+ before do
199
+ stub_get("/projects/1/hooks/1", "project_hook")
200
+ @hook = Brat.project_hook(1, 1)
201
+ end
202
+
203
+ it "should get the correct resource" do
204
+ expect(a_get("/projects/1/hooks/1")).to have_been_made
205
+ end
206
+
207
+ it "should return information about a hook" do
208
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
209
+ end
210
+ end
211
+
212
+ describe ".add_project_hook" do
213
+ context "without specified events" do
214
+ before do
215
+ stub_post("/projects/1/hooks", "project_hook")
216
+ @hook = Brat.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
217
+ end
218
+
219
+ it "should get the correct resource" do
220
+ body = {:url => "https://api.example.net/v1/webhooks/ci"}
221
+ expect(a_post("/projects/1/hooks").with(:body => body)).to have_been_made
222
+ end
223
+
224
+ it "should return information about an added hook" do
225
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
226
+ end
227
+ end
228
+
229
+ context "with specified events" do
230
+ before do
231
+ stub_post("/projects/1/hooks", "project_hook")
232
+ @hook = Brat.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true)
233
+ end
234
+
235
+ it "should get the correct resource" do
236
+ body = {:url => "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true"}
237
+ expect(a_post("/projects/1/hooks").with(:body => body)).to have_been_made
238
+ end
239
+
240
+ it "should return information about an added hook" do
241
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
242
+ end
243
+ end
244
+ end
245
+
246
+ describe ".edit_project_hook" do
247
+ before do
248
+ stub_put("/projects/1/hooks/1", "project_hook")
249
+ @hook = Brat.edit_project_hook(1, 1, "https://api.example.net/v1/webhooks/ci")
250
+ end
251
+
252
+ it "should get the correct resource" do
253
+ body = {:url => "https://api.example.net/v1/webhooks/ci"}
254
+ expect(a_put("/projects/1/hooks/1").with(:body => body)).to have_been_made
255
+ end
256
+
257
+ it "should return information about an edited hook" do
258
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
259
+ end
260
+ end
261
+
262
+ describe ".delete_project_hook" do
263
+ before do
264
+ stub_delete("/projects/1/hooks/1", "project_hook")
265
+ @hook = Brat.delete_project_hook(1, 1)
266
+ end
267
+
268
+ it "should get the correct resource" do
269
+ expect(a_delete("/projects/1/hooks/1")).to have_been_made
270
+ end
271
+
272
+ it "should return information about a deleted hook" do
273
+ expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
274
+ end
275
+ end
276
+
277
+ describe ".make_forked_from" do
278
+ before do
279
+ stub_post("/projects/42/fork/24", "project_fork_link")
280
+ @forked_project_link = Brat.make_forked_from(42, 24)
281
+ end
282
+
283
+ it "should get the correct resource" do
284
+ expect(a_post("/projects/42/fork/24")).to have_been_made
285
+ end
286
+
287
+ it "should return information about a forked project" do
288
+ expect(@forked_project_link.forked_from_project_id).to eq(24)
289
+ expect(@forked_project_link.forked_to_project_id).to eq(42)
290
+ end
291
+ end
292
+
293
+ describe ".remove_forked" do
294
+ before do
295
+ stub_delete("/projects/42/fork", "project_fork_link")
296
+ @forked_project_link = Brat.remove_forked(42)
297
+ end
298
+
299
+ it "should be sent to correct resource" do
300
+ expect(a_delete("/projects/42/fork")).to have_been_made
301
+ end
302
+
303
+ it "should return information about an unforked project" do
304
+ expect(@forked_project_link.forked_to_project_id).to eq(42)
305
+ end
306
+ end
307
+
308
+ describe ".deploy_keys" do
309
+ before do
310
+ stub_get("/projects/42/keys", "project_keys")
311
+ @deploy_keys = Brat.deploy_keys(42)
312
+ end
313
+
314
+ it "should get the correct resource" do
315
+ expect(a_get("/projects/42/keys")).to have_been_made
316
+ end
317
+
318
+ it "should return project deploy keys" do
319
+ expect(@deploy_keys).to be_an Array
320
+ expect(@deploy_keys.first.id).to eq 2
321
+ expect(@deploy_keys.first.title).to eq "Key Title"
322
+ expect(@deploy_keys.first.key).to match(/ssh-rsa/)
323
+ end
324
+ end
325
+
326
+ describe ".deploy_key" do
327
+ before do
328
+ stub_get("/projects/42/keys/2", "project_key")
329
+ @deploy_key = Brat.deploy_key(42, 2)
330
+ end
331
+
332
+ it "should get the correct resource" do
333
+ expect(a_get("/projects/42/keys/2")).to have_been_made
334
+ end
335
+
336
+ it "should return project deploy key" do
337
+ expect(@deploy_key.id).to eq 2
338
+ expect(@deploy_key.title).to eq "Key Title"
339
+ expect(@deploy_key.key).to match(/ssh-rsa/)
340
+ end
341
+ end
342
+
343
+ describe ".delete_deploy_key" do
344
+ before do
345
+ stub_delete("/projects/42/keys/2", "project_delete_key")
346
+ @deploy_key = Brat.delete_deploy_key(42, 2)
347
+ end
348
+
349
+ it "should get the correct resource" do
350
+ expect(a_delete("/projects/42/keys/2")).to have_been_made
351
+ end
352
+
353
+ it "should return information about a deleted key" do
354
+ expect(@deploy_key.id).to eq(2)
355
+ end
356
+ end
357
+ end