github_api 0.7.2 → 0.8.0
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.
- data/README.md +6 -5
- data/features/{events.feature → activity/events.feature} +8 -8
- data/features/{repos → activity}/starring.feature +6 -6
- data/features/{repos → activity}/watching.feature +6 -6
- data/features/cassettes/{events → activity/events}/issue.yml +0 -0
- data/features/cassettes/{events → activity/events}/network.yml +0 -0
- data/features/cassettes/{events → activity/events}/org.yml +0 -0
- data/features/cassettes/{events → activity/events}/performed.yml +0 -0
- data/features/cassettes/{events → activity/events}/public.yml +0 -0
- data/features/cassettes/{events → activity/events}/received.yml +0 -0
- data/features/cassettes/{events → activity/events}/repo.yml +0 -0
- data/features/cassettes/{events → activity/events}/user_org.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/list.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/star.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/starred.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/starring.yml +0 -0
- data/features/cassettes/{repos → activity}/starring/unstar.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/list.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/unwatch.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/watch.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/watched.yml +0 -0
- data/features/cassettes/{repos → activity}/watching/watching.yml +0 -0
- data/features/github_api.feature +3 -3
- data/lib/github_api.rb +1 -1
- data/lib/github_api/activity.rb +39 -0
- data/lib/github_api/{events.rb → activity/events.rb} +5 -5
- data/lib/github_api/activity/notifications.rb +162 -0
- data/lib/github_api/{repos → activity}/starring.rb +9 -9
- data/lib/github_api/{repos → activity}/watching.rb +9 -9
- data/lib/github_api/client.rb +6 -4
- data/lib/github_api/repos.rb +2 -14
- data/lib/github_api/response.rb +0 -1
- data/lib/github_api/version.rb +2 -2
- data/spec/fixtures/activity/notifications.json +32 -0
- data/spec/fixtures/activity/subscribed.json +8 -0
- data/spec/fixtures/activity/threads.json +32 -0
- data/spec/github/activity/activity_spec.rb +16 -0
- data/spec/github/activity/events/issue_spec.rb +63 -0
- data/spec/github/activity/events/network_spec.rb +61 -0
- data/spec/github/activity/events/org_spec.rb +60 -0
- data/spec/github/activity/events/performed_spec.rb +91 -0
- data/spec/github/activity/events/public_spec.rb +55 -0
- data/spec/github/activity/events/received_spec.rb +91 -0
- data/spec/github/activity/events/repository_spec.rb +65 -0
- data/spec/github/activity/events/user_org_spec.rb +63 -0
- data/spec/github/activity/notifications/create_spec.rb +44 -0
- data/spec/github/activity/notifications/delete_spec.rb +41 -0
- data/spec/github/activity/notifications/get_spec.rb +58 -0
- data/spec/github/activity/notifications/list_spec.rb +82 -0
- data/spec/github/activity/notifications/mark_spec.rb +74 -0
- data/spec/github/activity/notifications/subscribed_spec.rb +48 -0
- data/spec/github/activity/starring/list_spec.rb +64 -0
- data/spec/github/activity/starring/star_spec.rb +36 -0
- data/spec/github/activity/starring/starred_spec.rb +53 -0
- data/spec/github/activity/starring/starring_spec.rb +38 -0
- data/spec/github/activity/starring/unstar_spec.rb +37 -0
- data/spec/github/activity/watching/list_spec.rb +59 -0
- data/spec/github/activity/watching/unwatch_spec.rb +37 -0
- data/spec/github/activity/watching/watch_spec.rb +37 -0
- data/spec/github/activity/watching/watched_spec.rb +53 -0
- data/spec/github/activity/watching/watching_spec.rb +41 -0
- data/spec/github/authorization_spec.rb +2 -2
- data/spec/github/issues_spec.rb +1 -1
- data/spec/github/repos/comments/delete_spec.rb +2 -0
- data/spec/github/repos/delete_spec.rb +1 -1
- data/spec/github/repos/get_spec.rb +2 -2
- data/spec/github/repos/starring_spec.rb +0 -199
- data/spec/github/repos_spec.rb +0 -4
- data/spec/github/result_spec.rb +1 -1
- metadata +88 -62
- data/features/cassettes/git_data/tags/get.yml +0 -54
- data/features/git_data/tags.feature +0 -17
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/repos/watching_spec.rb +0 -203
@@ -1,203 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Github::Repos::Watching do
|
6
|
-
let(:github) { Github.new }
|
7
|
-
let(:user) { 'peter-murach' }
|
8
|
-
let(:repo) { 'github' }
|
9
|
-
|
10
|
-
after { github.user, github.repo, github.oauth_token = nil, nil, nil }
|
11
|
-
|
12
|
-
describe "#list" do
|
13
|
-
before do
|
14
|
-
stub_get("/repos/#{user}/#{repo}/subscribers").
|
15
|
-
to_return(:body => fixture("repos/watchers.json"),
|
16
|
-
:status => 200, :headers => {})
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should fail to get resource without username" do
|
20
|
-
expect {
|
21
|
-
github.repos.watching.list
|
22
|
-
}.to raise_error(ArgumentError)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should yield iterator if block given" do
|
26
|
-
github.repos.watching.should_receive(:list).
|
27
|
-
with(user, repo).and_yield('github')
|
28
|
-
github.repos.watching.list(user, repo) { |param| 'github' }
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should get the resources" do
|
32
|
-
github.repos.watching.list user, repo
|
33
|
-
a_get("/repos/#{user}/#{repo}/subscribers").should have_been_made
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return array of resources" do
|
37
|
-
watchers = github.repos.watching.list user, repo
|
38
|
-
watchers.should be_an Array
|
39
|
-
watchers.should have(1).items
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should return result of mash type" do
|
43
|
-
watchers = github.repos.watching.list user, repo
|
44
|
-
watchers.first.should be_a Hashie::Mash
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should get watcher information" do
|
48
|
-
watchers = github.repos.watching.list user, repo
|
49
|
-
watchers.first.login.should == 'octocat'
|
50
|
-
end
|
51
|
-
|
52
|
-
context "fail to find resource" do
|
53
|
-
before do
|
54
|
-
stub_get("/repos/#{user}/#{repo}/subscribers").
|
55
|
-
to_return(:body => "", :status => 404)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should return 404 not found message" do
|
59
|
-
expect {
|
60
|
-
github.repos.watching.list user, repo
|
61
|
-
}.to raise_error(Github::Error::NotFound)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end # list
|
65
|
-
|
66
|
-
describe "#watched" do
|
67
|
-
context "if user unauthenticated" do
|
68
|
-
it "should fail to get resource without username " do
|
69
|
-
stub_get("/user/subscriptions").
|
70
|
-
to_return(:body => '', :status => 401, :headers => {})
|
71
|
-
expect {
|
72
|
-
github.repos.watching.watched
|
73
|
-
}.to raise_error(Github::Error::Unauthorized)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should get the resource with username" do
|
77
|
-
stub_get("/users/#{user}/subscriptions").
|
78
|
-
to_return(:body => fixture("repos/watched.json"), :status => 200, :headers => {})
|
79
|
-
github.repos.watching.watched :user => user
|
80
|
-
a_get("/users/#{user}/subscriptions").should have_been_made
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context "if user authenticated" do
|
85
|
-
before do
|
86
|
-
github.oauth_token = OAUTH_TOKEN
|
87
|
-
stub_get("/user/subscriptions").
|
88
|
-
with(:query => {:access_token => OAUTH_TOKEN}).
|
89
|
-
to_return(:body => fixture("repos/watched.json"), :status => 200, :headers => {})
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should get the resources" do
|
93
|
-
github.repos.watching.watched
|
94
|
-
a_get("/user/subscriptions").
|
95
|
-
with(:query => {:access_token => OAUTH_TOKEN}).
|
96
|
-
should have_been_made
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should return array of resources" do
|
100
|
-
watched = github.repos.watching.watched
|
101
|
-
watched.should be_an Array
|
102
|
-
watched.should have(1).items
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should get watched information" do
|
106
|
-
watched = github.repos.watching.watched
|
107
|
-
watched.first.name.should == 'Hello-World'
|
108
|
-
watched.first.owner.login.should == 'octocat'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end # watched
|
112
|
-
|
113
|
-
describe "watching?" do
|
114
|
-
context "with username ane reponame passed" do
|
115
|
-
context "this repo is being watched by the user"
|
116
|
-
before do
|
117
|
-
stub_get("/user/subscriptions/#{user}/#{repo}").
|
118
|
-
to_return(:body => "", :status => 404,
|
119
|
-
:headers => {:user_agent => github.user_agent})
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should return false if resource not found" do
|
123
|
-
watching = github.repos.watching.watching? user, repo
|
124
|
-
watching.should be_false
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should return true if resoure found" do
|
128
|
-
stub_get("/user/subscriptions/#{user}/#{repo}").
|
129
|
-
to_return(:body => "", :status => 200,
|
130
|
-
:headers => {:user_agent => github.user_agent})
|
131
|
-
watching = github.repos.watching.watching? user, repo
|
132
|
-
watching.should be_true
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
context "without username and reponame passed" do
|
137
|
-
it "should fail validation " do
|
138
|
-
expect {
|
139
|
-
github.repos.watching.watching?(nil, nil)
|
140
|
-
}.to raise_error(ArgumentError)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end # watching?
|
144
|
-
|
145
|
-
describe "#watch" do
|
146
|
-
context "user authenticated" do
|
147
|
-
context "with correct information" do
|
148
|
-
before do
|
149
|
-
github.oauth_token = OAUTH_TOKEN
|
150
|
-
stub_put("/user/subscriptions/#{user}/#{repo}").
|
151
|
-
with(:query => {:access_token => OAUTH_TOKEN}).
|
152
|
-
to_return(:body => "", :status => 204, :headers => {})
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should successfully watch a repo" do
|
156
|
-
github.repos.watching.watch user, repo
|
157
|
-
a_put("/user/subscriptions/#{user}/#{repo}").
|
158
|
-
with(:query => {:access_token => OAUTH_TOKEN}).
|
159
|
-
should have_been_made
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context "user unauthenticated" do
|
165
|
-
it "should fail" do
|
166
|
-
stub_put("/user/subscriptions/#{user}/#{repo}").
|
167
|
-
to_return(:body => "", :status => 401, :headers => {})
|
168
|
-
expect {
|
169
|
-
github.repos.watching.watch user, repo
|
170
|
-
}.to raise_error(Github::Error::Unauthorized)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end # watch
|
174
|
-
|
175
|
-
describe "#unwatch" do
|
176
|
-
context "user authenticated" do
|
177
|
-
context "with correct information" do
|
178
|
-
before do
|
179
|
-
github.oauth_token = OAUTH_TOKEN
|
180
|
-
stub_delete("/user/subscriptions/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").
|
181
|
-
to_return(:body => "", :status => 204, :headers => {})
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should successfully watch a repo" do
|
185
|
-
github.repos.watching.unwatch user, repo
|
186
|
-
a_delete("/user/subscriptions/#{user}/#{repo}?access_token=#{OAUTH_TOKEN}").
|
187
|
-
should have_been_made
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context "user unauthenticated" do
|
193
|
-
it "should fail" do
|
194
|
-
stub_delete("/user/subscriptions/#{user}/#{repo}").
|
195
|
-
to_return(:body => "", :status => 401, :headers => {})
|
196
|
-
expect {
|
197
|
-
github.repos.watching.unwatch user, repo
|
198
|
-
}.to raise_error(Github::Error::Unauthorized)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end # unwatch
|
202
|
-
|
203
|
-
end # Github::Respos::Watching
|