github_api 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. metadata +4 -140
  2. data/LICENSE.txt +0 -20
  3. data/README.rdoc +0 -228
  4. data/Rakefile +0 -52
  5. data/features/github_api.feature +0 -50
  6. data/features/step_definitions/github_api_steps.rb +0 -11
  7. data/features/support/env.rb +0 -13
  8. data/lib/github_api.rb +0 -73
  9. data/lib/github_api/api.rb +0 -175
  10. data/lib/github_api/api/utils.rb +0 -9
  11. data/lib/github_api/authorization.rb +0 -73
  12. data/lib/github_api/authorizations.rb +0 -119
  13. data/lib/github_api/cache_control.rb +0 -19
  14. data/lib/github_api/client.rb +0 -55
  15. data/lib/github_api/compatibility.rb +0 -23
  16. data/lib/github_api/configuration.rb +0 -96
  17. data/lib/github_api/connection.rb +0 -81
  18. data/lib/github_api/core_ext/array.rb +0 -14
  19. data/lib/github_api/core_ext/hash.rb +0 -42
  20. data/lib/github_api/error.rb +0 -35
  21. data/lib/github_api/events.rb +0 -202
  22. data/lib/github_api/gists.rb +0 -200
  23. data/lib/github_api/gists/comments.rb +0 -86
  24. data/lib/github_api/git_data.rb +0 -26
  25. data/lib/github_api/git_data/blobs.rb +0 -51
  26. data/lib/github_api/git_data/commits.rb +0 -78
  27. data/lib/github_api/git_data/references.rb +0 -113
  28. data/lib/github_api/git_data/tags.rb +0 -78
  29. data/lib/github_api/git_data/trees.rb +0 -89
  30. data/lib/github_api/issues.rb +0 -215
  31. data/lib/github_api/issues/comments.rb +0 -110
  32. data/lib/github_api/issues/events.rb +0 -50
  33. data/lib/github_api/issues/labels.rb +0 -191
  34. data/lib/github_api/issues/milestones.rb +0 -119
  35. data/lib/github_api/mime_type.rb +0 -55
  36. data/lib/github_api/orgs.rb +0 -95
  37. data/lib/github_api/orgs/members.rb +0 -120
  38. data/lib/github_api/orgs/teams.rb +0 -245
  39. data/lib/github_api/pull_requests.rb +0 -224
  40. data/lib/github_api/pull_requests/comments.rb +0 -144
  41. data/lib/github_api/repos.rb +0 -286
  42. data/lib/github_api/repos/collaborators.rb +0 -81
  43. data/lib/github_api/repos/commits.rb +0 -180
  44. data/lib/github_api/repos/downloads.rb +0 -155
  45. data/lib/github_api/repos/forks.rb +0 -48
  46. data/lib/github_api/repos/hooks.rb +0 -173
  47. data/lib/github_api/repos/keys.rb +0 -104
  48. data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
  49. data/lib/github_api/repos/watching.rb +0 -94
  50. data/lib/github_api/request.rb +0 -84
  51. data/lib/github_api/request/basic_auth.rb +0 -31
  52. data/lib/github_api/request/caching.rb +0 -33
  53. data/lib/github_api/request/oauth2.rb +0 -33
  54. data/lib/github_api/response.rb +0 -28
  55. data/lib/github_api/response/helpers.rb +0 -14
  56. data/lib/github_api/response/jsonize.rb +0 -26
  57. data/lib/github_api/response/mashify.rb +0 -24
  58. data/lib/github_api/response/raise_error.rb +0 -33
  59. data/lib/github_api/result.rb +0 -42
  60. data/lib/github_api/users.rb +0 -84
  61. data/lib/github_api/users/emails.rb +0 -49
  62. data/lib/github_api/users/followers.rb +0 -98
  63. data/lib/github_api/users/keys.rb +0 -84
  64. data/lib/github_api/version.rb +0 -12
  65. data/spec/README.rdoc +0 -22
  66. data/spec/coverage_adapter.rb +0 -14
  67. data/spec/fixtures/auths/authorization.json +0 -14
  68. data/spec/fixtures/auths/authorizations.json +0 -16
  69. data/spec/fixtures/events/events.json +0 -29
  70. data/spec/fixtures/issues/issue.json +0 -56
  71. data/spec/fixtures/issues/issues.json +0 -58
  72. data/spec/fixtures/orgs/members.json +0 -9
  73. data/spec/fixtures/orgs/org.json +0 -18
  74. data/spec/fixtures/orgs/orgs.json +0 -8
  75. data/spec/fixtures/orgs/team.json +0 -8
  76. data/spec/fixtures/orgs/team_repos.json +0 -29
  77. data/spec/fixtures/orgs/teams.json +0 -7
  78. data/spec/fixtures/repos/branches.json +0 -9
  79. data/spec/fixtures/repos/collaborators.json +0 -8
  80. data/spec/fixtures/repos/commit.json +0 -53
  81. data/spec/fixtures/repos/commit_comment.json +0 -16
  82. data/spec/fixtures/repos/commit_comments.json +0 -18
  83. data/spec/fixtures/repos/commits.json +0 -27
  84. data/spec/fixtures/repos/contributors.json +0 -8
  85. data/spec/fixtures/repos/download.json +0 -10
  86. data/spec/fixtures/repos/download_s3.json +0 -21
  87. data/spec/fixtures/repos/downloads.json +0 -12
  88. data/spec/fixtures/repos/fork.json +0 -27
  89. data/spec/fixtures/repos/forks.json +0 -29
  90. data/spec/fixtures/repos/hook.json +0 -15
  91. data/spec/fixtures/repos/hooks.json +0 -10
  92. data/spec/fixtures/repos/key.json +0 -6
  93. data/spec/fixtures/repos/keys.json +0 -8
  94. data/spec/fixtures/repos/languages.json +0 -4
  95. data/spec/fixtures/repos/repo.json +0 -90
  96. data/spec/fixtures/repos/repo_comments.json +0 -18
  97. data/spec/fixtures/repos/repos.json +0 -29
  98. data/spec/fixtures/repos/tags.json +0 -11
  99. data/spec/fixtures/repos/teams.json +0 -7
  100. data/spec/fixtures/repos/watched.json +0 -29
  101. data/spec/fixtures/repos/watchers.json +0 -8
  102. data/spec/fixtures/users/user.json +0 -32
  103. data/spec/github/api_spec.rb +0 -25
  104. data/spec/github/authorization_spec.rb +0 -176
  105. data/spec/github/authorizations_spec.rb +0 -242
  106. data/spec/github/client_spec.rb +0 -50
  107. data/spec/github/core_ext/hash_spec.rb +0 -44
  108. data/spec/github/events_spec.rb +0 -491
  109. data/spec/github/gists/comments_spec.rb +0 -5
  110. data/spec/github/gists_spec.rb +0 -5
  111. data/spec/github/git_data/blobs_spec.rb +0 -5
  112. data/spec/github/git_data/commits_spec.rb +0 -5
  113. data/spec/github/git_data/references_spec.rb +0 -5
  114. data/spec/github/git_data/tags_spec.rb +0 -5
  115. data/spec/github/git_data/trees_spec.rb +0 -5
  116. data/spec/github/git_data_spec.rb +0 -5
  117. data/spec/github/issues/comments_spec.rb +0 -5
  118. data/spec/github/issues/events_spec.rb +0 -5
  119. data/spec/github/issues/labels_spec.rb +0 -5
  120. data/spec/github/issues/milestones_spec.rb +0 -5
  121. data/spec/github/issues_spec.rb +0 -287
  122. data/spec/github/mime_type_spec.rb +0 -70
  123. data/spec/github/orgs/members_spec.rb +0 -275
  124. data/spec/github/orgs/teams_spec.rb +0 -563
  125. data/spec/github/orgs_spec.rb +0 -160
  126. data/spec/github/repos/collaborators_spec.rb +0 -169
  127. data/spec/github/repos/commits_spec.rb +0 -424
  128. data/spec/github/repos/downloads_spec.rb +0 -236
  129. data/spec/github/repos/forks_spec.rb +0 -103
  130. data/spec/github/repos/hooks_spec.rb +0 -307
  131. data/spec/github/repos/keys_spec.rb +0 -216
  132. data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
  133. data/spec/github/repos/watching_spec.rb +0 -222
  134. data/spec/github/repos_spec.rb +0 -571
  135. data/spec/github/result_spec.rb +0 -43
  136. data/spec/github/users_spec.rb +0 -140
  137. data/spec/github_spec.rb +0 -109
  138. data/spec/spec_helper.rb +0 -86
@@ -1,216 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Repos::Keys do
4
-
5
- let(:github) { Github.new }
6
- let(:user) { 'peter-murach'}
7
- let(:repo) { 'github' }
8
-
9
- describe "keys" do
10
-
11
- context "resource found" do
12
- before do
13
- stub_get("/repos/#{user}/#{repo}/keys").
14
- to_return(:body => fixture("repos/keys.json"), :status => 200, :headers => {})
15
- end
16
-
17
- it "should fail to get resource without username" do
18
- github.user, github.repo = nil, nil
19
- expect { github.repos.keys }.to raise_error(ArgumentError)
20
- end
21
-
22
- it "should get the resources" do
23
- github.repos.keys(user, repo)
24
- a_get("/repos/#{user}/#{repo}/keys").should have_been_made
25
- end
26
-
27
- it "should return array of resources" do
28
- keys = github.repos.keys(user, repo)
29
- keys.should be_an Array
30
- keys.should have(1).items
31
- end
32
-
33
- it "should get key information" do
34
- keys = github.repos.keys(user, repo)
35
- keys.first.title.should == 'octocat@octomac'
36
- end
37
- end
38
-
39
- context "resource not found" do
40
- before do
41
- stub_get("/repos/#{user}/#{repo}/keys").
42
- to_return(:body => fixture("repos/keys.json"), :status => 404)
43
- end
44
-
45
- it "should fail to retrieve resource" do
46
- expect {
47
- github.repos.keys user, repo
48
- }.to raise_error(Github::ResourceNotFound)
49
- end
50
- end
51
-
52
- end
53
-
54
- describe "get_key" do
55
- let(:key_id) { 1 }
56
-
57
- context "resource found" do
58
- before do
59
- stub_get("/repos/#{user}/#{repo}/keys/#{key_id}").
60
- to_return(:body => fixture("repos/key.json"), :status => 200)
61
- end
62
-
63
- it "should fail to get resource without key" do
64
- expect {
65
- github.repos.get_key(user, repo, nil)
66
- }.to raise_error(ArgumentError)
67
- end
68
-
69
- it "should get the resource" do
70
- github.repos.get_key(user, repo, key_id)
71
- a_get("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made
72
- end
73
-
74
- it "should get key information" do
75
- key = github.repos.get_key(user, repo, key_id)
76
- key.id.should == key_id
77
- end
78
- end
79
-
80
- context "resource not found" do
81
- before do
82
- stub_get("/repos/#{user}/#{repo}/keys/#{key_id}").
83
- to_return(:body => fixture("repos/keys.json"), :status => 404)
84
- end
85
-
86
- it "should fail to retrieve resource" do
87
- expect {
88
- github.repos.get_key(user, repo, key_id)
89
- }.to raise_error(Github::ResourceNotFound)
90
- end
91
- end
92
- end
93
-
94
- describe "create_key" do
95
- let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }
96
-
97
- context "resource created" do
98
- before do
99
- stub_post("/repos/#{user}/#{repo}/keys").with(inputs).
100
- to_return(:body => fixture("repos/key.json"), :status => 201)
101
- end
102
-
103
- it "should fail to create resource if 'title' input is missing" do
104
- expect {
105
- github.repos.create_key(user, repo, :key => 'ssh-rsa AAA...')
106
- }.to raise_error(ArgumentError)
107
- end
108
-
109
- it "should fail to create resource if 'key' input is missing" do
110
- expect {
111
- github.repos.create_key(user, repo, :title => 'octocat@octomac')
112
- }.to raise_error(ArgumentError)
113
- end
114
-
115
- it "should create the resource" do
116
- github.repos.create_key(user, repo, inputs)
117
- a_post("/repos/#{user}/#{repo}/keys").with(inputs).should have_been_made
118
- end
119
-
120
- it "should get the key information back" do
121
- key = github.repos.create_key(user, repo, inputs)
122
- key.title.should == 'octocat@octomac'
123
- end
124
- end
125
-
126
- context "failed to create resource" do
127
- before do
128
- stub_post("/repos/#{user}/#{repo}/keys").
129
- to_return(:body => fixture("repos/key.json"), :status => 404)
130
- end
131
-
132
- it "should fail to retrieve resource" do
133
- expect {
134
- github.repos.create_key(user, repo, inputs)
135
- }.to raise_error(Github::ResourceNotFound)
136
- end
137
- end
138
- end
139
-
140
- describe "edit_key" do
141
- let(:key_id) { 1 }
142
- let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }
143
-
144
- context "resource edited successfully" do
145
- before do
146
- stub_patch("/repos/#{user}/#{repo}/keys/#{key_id}").
147
- to_return(:body => fixture("repos/key.json"), :status => 200)
148
- end
149
-
150
- it "should edit the resource" do
151
- github.repos.edit_key(user, repo, key_id, inputs)
152
- a_patch("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made
153
- end
154
-
155
- it "should get the key information back" do
156
- key = github.repos.edit_key(user, repo, key_id, inputs)
157
- key.id.should == key_id
158
- key.title.should == 'octocat@octomac'
159
- end
160
- end
161
-
162
- context "failed to edit resource" do
163
- before do
164
- stub_patch("/repos/#{user}/#{repo}/keys/#{key_id}").
165
- to_return(:body => fixture("repos/key.json"), :status => 404)
166
- end
167
-
168
- it "should fail to retrieve resource" do
169
- expect {
170
- github.repos.edit_key(user, repo, key_id, inputs)
171
- }.to raise_error(Github::ResourceNotFound)
172
- end
173
- end
174
-
175
- end
176
-
177
- describe "delete_key" do
178
- let(:key_id) { 1 }
179
-
180
- context "resource found successfully" do
181
- before do
182
- stub_delete("/repos/#{user}/#{repo}/keys/#{key_id}").
183
- to_return(:body => "", :status => 204, :headers => { :content_type => "application/json; charset=utf-8"} )
184
- end
185
-
186
- it "should fail to delete without 'user/repo' parameters" do
187
- github.user, github.repo = nil, nil
188
- expect { github.repos.delete_key }.to raise_error(ArgumentError)
189
- end
190
-
191
- it "should fail to delete resource without key id" do
192
- expect {
193
- github.repos.delete_key user, repo, nil
194
- }.to raise_error(ArgumentError)
195
- end
196
-
197
- it "should delete the resource" do
198
- github.repos.delete_key(user, repo, key_id)
199
- a_delete("/repos/#{user}/#{repo}/keys/#{key_id}").should have_been_made
200
- end
201
- end
202
-
203
- context "failed to find resource" do
204
- before do
205
- stub_delete("/repos/#{user}/#{repo}/keys/#{key_id}").
206
- to_return(:body => "", :status => 404)
207
- end
208
- it "should fail to find resource" do
209
- expect {
210
- github.repos.delete_key(user, repo, key_id)
211
- }.to raise_error(Github::ResourceNotFound)
212
- end
213
- end
214
- end
215
-
216
- end # Github::Repos::Keys
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Github::Repos::PubSubHubbub do
4
-
5
- let(:github) { Github.new }
6
- let(:topic) { "https://github.com/peter-murach/github/events/push"}
7
- let(:callback) { "github://campfire?subdomain=github&room=Commits&token=abc123" }
8
- let(:hub_inputs) {
9
- {
10
- "hub.mode" => 'subscribe',
11
- "hub.topic" => topic,
12
- "hub.callback" => callback,
13
- "hub.verify" => 'sync',
14
- "hub.secret" => ''
15
- }
16
- }
17
-
18
- describe "subscribe" do
19
- context "success" do
20
- before do
21
- github.oauth_token = OAUTH_TOKEN
22
- stub_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).
23
- to_return(:body => '', :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
24
- end
25
-
26
- after do
27
- github.oauth_token = nil
28
- end
29
-
30
- it "should subscribe to hub" do
31
- github.repos.subscribe topic, callback
32
- a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
33
- end
34
- end
35
-
36
- context "failure" do
37
- before do
38
- github.oauth_token = OAUTH_TOKEN
39
- stub_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).
40
- to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
41
- end
42
-
43
- it "should fail to subscribe to hub" do
44
- expect {
45
- github.repos.subscribe topic, callback
46
- }.to raise_error(Github::ResourceNotFound)
47
- end
48
- end
49
- end
50
-
51
- describe "unsubscribe" do
52
- context "success" do
53
- before do
54
- github.oauth_token = OAUTH_TOKEN
55
- stub_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs.merge("hub.mode" => 'unsubscribe')).
56
- to_return(:body => '', :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
57
- end
58
-
59
- after do
60
- github.oauth_token = nil
61
- end
62
-
63
- it "should subscribe to hub" do
64
- github.repos.unsubscribe topic, callback
65
- a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
66
- end
67
- end
68
-
69
- context "failure" do
70
- before do
71
- github.oauth_token = OAUTH_TOKEN
72
- stub_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs.merge("hub.mode" => 'unsubscribe')).
73
- to_return(:body => '', :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
74
- end
75
-
76
- it "should fail to subscribe to hub" do
77
- expect {
78
- github.repos.unsubscribe topic, callback
79
- }.to raise_error(Github::ResourceNotFound)
80
- end
81
- end
82
- end
83
- end # Github::Repos::PubSubHubbub
@@ -1,222 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Github::Repos::Watching do
6
-
7
- let(:github) { Github.new }
8
- let(:user) { 'peter-murach' }
9
- let(:repo) { 'github' }
10
-
11
- describe "watchers" do
12
- before do
13
- github.oauth_token = nil
14
- stub_get("/repos/#{user}/#{repo}/watchers").
15
- to_return(:body => fixture("repos/watchers.json"), :status => 200, :headers => {})
16
- end
17
-
18
- it "should fail to get resource without username" do
19
- github.user, github.repo = nil, nil
20
- expect { github.repos.watchers }.to raise_error(ArgumentError)
21
- end
22
-
23
- it "should yield iterator if block given" do
24
- github.repos.should_receive(:watchers).with(user, repo).and_yield('github')
25
- github.repos.watchers(user, repo) { |param| 'github' }
26
- end
27
-
28
- it "should get the resources" do
29
- github.repos.watchers(user, repo)
30
- a_get("/repos/#{user}/#{repo}/watchers").should have_been_made
31
- end
32
-
33
- it "should return array of resources" do
34
- watchers = github.repos.watchers(user, repo)
35
- watchers.should be_an Array
36
- watchers.should have(1).items
37
- end
38
-
39
- it "should return result of mash type" do
40
- watchers = github.repos.watchers user, repo
41
- watchers.first.should be_a Hashie::Mash
42
- end
43
-
44
- it "should get watcher information" do
45
- watchers = github.repos.watchers(user, repo)
46
- watchers.first.login.should == 'octocat'
47
- end
48
-
49
- context "fail to find resource" do
50
- before do
51
- stub_get("/repos/#{user}/#{repo}/watchers").
52
- to_return(:body => "", :status => 404)
53
- end
54
-
55
- it "should return 404 not found message" do
56
- lambda { github.repos.watchers(user, repo) }.should raise_error(Github::ResourceNotFound)
57
- end
58
-
59
- end
60
-
61
- end
62
-
63
- describe "watched" do
64
-
65
- context "if user unauthenticated" do
66
- before do
67
- github.oauth_token = nil
68
- WebMock.reset!
69
- end
70
-
71
- it "should fail to get resource without username " do
72
- stub_get("/user/watched").
73
- to_return(:body => fixture("repos/watched.json"), :status => 401, :headers => {})
74
- expect {
75
- github.user = nil
76
- github.repos.watched
77
- }.to raise_error(Github::Unauthorised)
78
- end
79
-
80
- it "should get the resource with username" do
81
- stub_get("/users/#{user}/watched").
82
- to_return(:body => fixture("repos/watched.json"), :status => 200, :headers => {})
83
- github.repos.watched(user)
84
- a_get("/users/#{user}/watched").should have_been_made
85
- end
86
- end
87
-
88
- context "if user authenticated" do
89
- before do
90
- github.user = nil
91
- github.oauth_token = OAUTH_TOKEN
92
- stub_get("/user/watched?access_token=#{OAUTH_TOKEN}").
93
- to_return(:body => fixture("repos/watched.json"), :status => 200, :headers => {})
94
- end
95
-
96
- it "should get the resources" do
97
- github.repos.watched
98
- a_get("/user/watched?access_token=#{OAUTH_TOKEN}").should have_been_made
99
- end
100
-
101
- it "should return array of resources" do
102
- watched = github.repos.watched
103
- watched.should be_an Array
104
- watched.should have(1).items
105
- end
106
-
107
- it "should get watched information" do
108
- watched = github.repos.watched
109
- watched.first.name.should == 'Hello-World'
110
- watched.first.owner.login.should == 'octocat'
111
- end
112
- end
113
- end
114
-
115
- describe "watching?" do
116
-
117
- context "with username ane reponame passed" do
118
-
119
- context "this repo is being watched by the user"
120
- before do
121
- github.oauth_token = nil
122
- github.user = nil
123
- stub_get("/user/watched/#{user}/#{repo}").
124
- to_return(:body => "", :status => 404, :headers => {:user_agent => github.user_agent})
125
- end
126
-
127
- it "should return false if resource not found" do
128
- watching = github.repos.watching? user, repo
129
- watching.should be_false
130
- end
131
-
132
- it "should return true if resoure found" do
133
- stub_get("/user/watched/#{user}/#{repo}").
134
- to_return(:body => "", :status => 200, :headers => {:user_agent => github.user_agent})
135
- watching = github.repos.watching? user, repo
136
- watching.should be_true
137
- end
138
-
139
- end
140
-
141
- context "without username and reponame passed" do
142
- it "should fail validation " do
143
- expect { github.repos.watching?(nil, nil) }.to raise_error(ArgumentError)
144
- end
145
- end
146
- end
147
-
148
- describe "start_watching" do
149
-
150
- context "user authenticated" do
151
-
152
- context "with correct information" do
153
- before do
154
- github.user, github.repo = nil, nil
155
- github.oauth_token = OAUTH_TOKEN
156
- stub_put("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").
157
- to_return(:body => "", :status => 204, :headers => {})
158
- end
159
-
160
- after do
161
- github.oauth_token = nil # ensure authentication is reset
162
- end
163
-
164
- it "should successfully watch a repo" do
165
- github.repos.start_watching(user, repo)
166
- a_put("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").should have_been_made
167
- end
168
- end
169
-
170
- context "without correct information" do
171
-
172
- end
173
- end
174
-
175
- context "user unauthenticated" do
176
- it "should fail" do
177
- github.oauth_token = nil
178
- stub_put("/user/watched/#{user}/#{repo}").
179
- to_return(:body => "", :status => 401, :headers => {})
180
- expect {
181
- github.repos.start_watching(user, repo)
182
- }.to raise_error(Github::Unauthorised)
183
- end
184
- end
185
- end
186
-
187
- describe "stop_watching" do
188
-
189
- context "user authenticated" do
190
-
191
- context "with correct information" do
192
- before do
193
- github.user, github.repo = nil, nil
194
- github.oauth_token = OAUTH_TOKEN
195
- stub_delete("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").
196
- to_return(:body => "", :status => 204, :headers => {})
197
- end
198
-
199
- it "should successfully watch a repo" do
200
- github.repos.stop_watching(user, repo)
201
- a_delete("/user/watched/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").should have_been_made
202
- end
203
- end
204
-
205
- context "without correct information" do
206
-
207
- end
208
- end
209
-
210
- context "user unauthenticated" do
211
- it "should fail" do
212
- github.oauth_token = nil
213
- stub_delete("/user/watched/#{user}/#{repo}").
214
- to_return(:body => "", :status => 401, :headers => {})
215
- expect {
216
- github.repos.stop_watching(user, repo)
217
- }.to raise_error(Github::Unauthorised)
218
- end
219
- end
220
- end
221
-
222
- end # Github::Respos::Watching