github_api 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.md +2 -1
  2. data/features/cassettes/orgs/members/list.yml +139 -0
  3. data/features/cassettes/orgs/members/list_public.yml +140 -0
  4. data/features/cassettes/orgs/members/member_false.yml +52 -0
  5. data/features/cassettes/orgs/members/member_public_false.yml +55 -0
  6. data/features/cassettes/orgs/members/member_public_true.yml +48 -0
  7. data/features/orgs/members.feature +57 -0
  8. data/lib/github_api/connection.rb +4 -4
  9. data/lib/github_api/orgs/members.rb +28 -35
  10. data/lib/github_api/orgs/teams.rb +14 -13
  11. data/lib/github_api/version.rb +1 -1
  12. data/spec/github/gists/create_spec.rb +64 -0
  13. data/spec/github/gists/delete_spec.rb +31 -0
  14. data/spec/github/gists/edit_spec.rb +60 -0
  15. data/spec/github/gists/fork_spec.rb +41 -0
  16. data/spec/github/gists/get_spec.rb +47 -0
  17. data/spec/github/gists/gists_spec.rb +7 -0
  18. data/spec/github/gists/is_starred_spec.rb +42 -0
  19. data/spec/github/gists/list_spec.rb +78 -0
  20. data/spec/github/gists/star_spec.rb +30 -0
  21. data/spec/github/gists/starred_spec.rb +44 -0
  22. data/spec/github/gists/unstar_spec.rb +30 -0
  23. data/spec/github/orgs/members/conceal_spec.rb +35 -0
  24. data/spec/github/orgs/members/delete_spec.rb +33 -0
  25. data/spec/github/orgs/members/list_spec.rb +82 -0
  26. data/spec/github/orgs/members/member_spec.rb +65 -0
  27. data/spec/github/orgs/members/publicize_spec.rb +35 -0
  28. data/spec/github/orgs/members_spec.rb +0 -277
  29. data/spec/github/orgs/teams/add_member_spec.rb +38 -0
  30. data/spec/github/orgs/teams/add_repo_spec.rb +39 -0
  31. data/spec/github/orgs/teams/create_spec.rb +58 -0
  32. data/spec/github/orgs/teams/delete_spec.rb +36 -0
  33. data/spec/github/orgs/teams/edit_spec.rb +57 -0
  34. data/spec/github/orgs/teams/get_spec.rb +45 -0
  35. data/spec/github/orgs/teams/list_members_spec.rb +49 -0
  36. data/spec/github/orgs/teams/list_repos_spec.rb +49 -0
  37. data/spec/github/orgs/teams/list_spec.rb +49 -0
  38. data/spec/github/orgs/teams/remove_member_spec.rb +40 -0
  39. data/spec/github/orgs/teams/remove_repo_spec.rb +40 -0
  40. data/spec/github/orgs/teams/team_member_spec.rb +40 -0
  41. data/spec/github/orgs/teams/team_repo_spec.rb +43 -0
  42. data/spec/github/orgs/teams_spec.rb +2 -566
  43. metadata +67 -33
  44. data/spec/github/gists_spec.rb +0 -470
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-20 00:00:00.000000000Z
12
+ date: 2013-01-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
16
- requirement: &2154510820 !ruby/object:Gem::Requirement
16
+ requirement: &2160548320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2154510820
24
+ version_requirements: *2160548320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &2154510320 !ruby/object:Gem::Requirement
27
+ requirement: &2160547820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2154510320
35
+ version_requirements: *2160547820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &2154509860 !ruby/object:Gem::Requirement
38
+ requirement: &2160547360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2154509860
46
+ version_requirements: *2160547360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: oauth2
49
- requirement: &2154509480 !ruby/object:Gem::Requirement
49
+ requirement: &2160546980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2154509480
57
+ version_requirements: *2160546980
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &2154508940 !ruby/object:Gem::Requirement
60
+ requirement: &2160546440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.5.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2154508940
68
+ version_requirements: *2160546440
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &2154508440 !ruby/object:Gem::Requirement
71
+ requirement: &2160545940 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2154508440
79
+ version_requirements: *2160545940
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: cucumber
82
- requirement: &2154507980 !ruby/object:Gem::Requirement
82
+ requirement: &2160545480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2154507980
90
+ version_requirements: *2160545480
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &2154507520 !ruby/object:Gem::Requirement
93
+ requirement: &2160545020 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.9.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2154507520
101
+ version_requirements: *2160545020
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: vcr
104
- requirement: &2154507060 !ruby/object:Gem::Requirement
104
+ requirement: &2160544560 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 2.4.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2154507060
112
+ version_requirements: *2160544560
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: simplecov
115
- requirement: &2154506600 !ruby/object:Gem::Requirement
115
+ requirement: &2160544100 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.7.1
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2154506600
123
+ version_requirements: *2160544100
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: guard
126
- requirement: &2154506220 !ruby/object:Gem::Requirement
126
+ requirement: &2160543720 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2154506220
134
+ version_requirements: *2160543720
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: guard-rspec
137
- requirement: &2154505760 !ruby/object:Gem::Requirement
137
+ requirement: &2160543260 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2154505760
145
+ version_requirements: *2160543260
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: guard-cucumber
148
- requirement: &2154505340 !ruby/object:Gem::Requirement
148
+ requirement: &2160542840 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2154505340
156
+ version_requirements: *2160542840
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rake
159
- requirement: &2154504920 !ruby/object:Gem::Requirement
159
+ requirement: &2160650960 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *2154504920
167
+ version_requirements: *2160650960
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: bundler
170
- requirement: &2154504500 !ruby/object:Gem::Requirement
170
+ requirement: &2160650540 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,7 +175,7 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *2154504500
178
+ version_requirements: *2160650540
179
179
  description: ! ' Ruby wrapper that supports all of the GitHub API v3 methods(nearly
180
180
  200). It''s build in a modular way, that is, you can either instantiate the whole
181
181
  api wrapper Github.new or use parts of it e.i. Github::Repos.new if working solely
@@ -263,6 +263,11 @@ files:
263
263
  - features/cassettes/orgs/get.yml
264
264
  - features/cassettes/orgs/list/oauth_user.yml
265
265
  - features/cassettes/orgs/list/user.yml
266
+ - features/cassettes/orgs/members/list.yml
267
+ - features/cassettes/orgs/members/list_public.yml
268
+ - features/cassettes/orgs/members/member_false.yml
269
+ - features/cassettes/orgs/members/member_public_false.yml
270
+ - features/cassettes/orgs/members/member_public_true.yml
266
271
  - features/cassettes/pagination/issues/list/first.yml
267
272
  - features/cassettes/pagination/issues/list/last.yml
268
273
  - features/cassettes/pagination/issues/list/next.yml
@@ -325,6 +330,7 @@ files:
325
330
  - features/issues.feature
326
331
  - features/markdown.feature
327
332
  - features/options.feature
333
+ - features/orgs/members.feature
328
334
  - features/orgs.feature
329
335
  - features/pagination.feature
330
336
  - features/pull_requests/comments.feature
@@ -584,7 +590,17 @@ files:
584
590
  - spec/github/error/unknown_value_spec.rb
585
591
  - spec/github/error/validations_spec.rb
586
592
  - spec/github/gists/comments_spec.rb
587
- - spec/github/gists_spec.rb
593
+ - spec/github/gists/create_spec.rb
594
+ - spec/github/gists/delete_spec.rb
595
+ - spec/github/gists/edit_spec.rb
596
+ - spec/github/gists/fork_spec.rb
597
+ - spec/github/gists/get_spec.rb
598
+ - spec/github/gists/gists_spec.rb
599
+ - spec/github/gists/is_starred_spec.rb
600
+ - spec/github/gists/list_spec.rb
601
+ - spec/github/gists/star_spec.rb
602
+ - spec/github/gists/starred_spec.rb
603
+ - spec/github/gists/unstar_spec.rb
588
604
  - spec/github/git_data/blobs/create_spec.rb
589
605
  - spec/github/git_data/blobs/get_spec.rb
590
606
  - spec/github/git_data/blobs_spec.rb
@@ -643,8 +659,26 @@ files:
643
659
  - spec/github/orgs/edit_spec.rb
644
660
  - spec/github/orgs/get_spec.rb
645
661
  - spec/github/orgs/list_spec.rb
662
+ - spec/github/orgs/members/conceal_spec.rb
663
+ - spec/github/orgs/members/delete_spec.rb
664
+ - spec/github/orgs/members/list_spec.rb
665
+ - spec/github/orgs/members/member_spec.rb
666
+ - spec/github/orgs/members/publicize_spec.rb
646
667
  - spec/github/orgs/members_spec.rb
647
668
  - spec/github/orgs/orgs_spec.rb
669
+ - spec/github/orgs/teams/add_member_spec.rb
670
+ - spec/github/orgs/teams/add_repo_spec.rb
671
+ - spec/github/orgs/teams/create_spec.rb
672
+ - spec/github/orgs/teams/delete_spec.rb
673
+ - spec/github/orgs/teams/edit_spec.rb
674
+ - spec/github/orgs/teams/get_spec.rb
675
+ - spec/github/orgs/teams/list_members_spec.rb
676
+ - spec/github/orgs/teams/list_repos_spec.rb
677
+ - spec/github/orgs/teams/list_spec.rb
678
+ - spec/github/orgs/teams/remove_member_spec.rb
679
+ - spec/github/orgs/teams/remove_repo_spec.rb
680
+ - spec/github/orgs/teams/team_member_spec.rb
681
+ - spec/github/orgs/teams/team_repo_spec.rb
648
682
  - spec/github/orgs/teams_spec.rb
649
683
  - spec/github/page_iterator_spec.rb
650
684
  - spec/github/page_links_spec.rb
@@ -1,470 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Github::Gists do
6
- let(:github) { Github.new }
7
- let(:user) { 'peter-murach' }
8
- let(:gist_id) { '1' }
9
-
10
- after { reset_authentication_for(github) }
11
-
12
- describe "#list" do
13
- it { github.gists.should respond_to :all }
14
-
15
- context "- unauthenticated user" do
16
- context "resource found" do
17
- before do
18
- stub_get("/users/#{user}/gists").
19
- to_return(:body => fixture('gists/gists.json'), :status => 200,
20
- :headers => {:content_type => "application/json; charset=utf-8"})
21
- end
22
-
23
- it "should get the resources" do
24
- github.gists.list :user => user
25
- a_get("/users/#{user}/gists").should have_been_made
26
- end
27
-
28
- it "should return array of resources" do
29
- gists = github.gists.list :user => user
30
- gists.should be_an Array
31
- gists.should have(1).items
32
- end
33
-
34
- it "should be a mash type" do
35
- gists = github.gists.list :user => user
36
- gists.first.should be_a Hashie::Mash
37
- end
38
-
39
- it "should get gist information" do
40
- gists = github.gists.list :user => user
41
- gists.first.user.login.should == 'octocat'
42
- end
43
-
44
- it "should yield to a block" do
45
- github.gists.should_receive(:list).with(user).and_yield('web')
46
- github.gists.list(user) { |param| 'web' }
47
- end
48
- end
49
-
50
- context "resource not found" do
51
- before do
52
- stub_get("/users/#{user}/gists").
53
- to_return(:body => "", :status => [404, "Not Found"])
54
- end
55
-
56
- it "should return 404 with a message 'Not Found'" do
57
- expect {
58
- github.gists.list :user => user
59
- }.to raise_error(Github::Error::NotFound)
60
- end
61
- end
62
- end # unauthenticated user
63
-
64
- context '- public' do
65
- before do
66
- stub_get("/gists/public").
67
- to_return(:body => fixture('gists/gists.json'), :status => 200,
68
- :headers => {:content_type => "application/json; charset=utf-8"})
69
- end
70
-
71
- it "should get the resources" do
72
- github.gists.list
73
- a_get("/gists/public").should have_been_made
74
- end
75
- end
76
-
77
- context '- authenticated user' do
78
- before do
79
- github.oauth_token = OAUTH_TOKEN
80
- stub_get("/gists").
81
- with(:query => {:access_token => OAUTH_TOKEN}).
82
- to_return(:body => fixture('gists/gists.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
83
- end
84
- # after { github.oauth_token = nil }
85
-
86
- it "should get the resources" do
87
- github.gists.list
88
- a_get("/gists").with(:query => {:access_token => OAUTH_TOKEN}).
89
- should have_been_made
90
- end
91
- end
92
- end # list
93
-
94
- describe "#starred" do
95
- context "resource found" do
96
- before do
97
- stub_get("/gists/starred").
98
- to_return(:body => fixture('gists/gists.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
99
- end
100
-
101
- it "should get the resources" do
102
- github.gists.starred
103
- a_get("/gists/starred").should have_been_made
104
- end
105
-
106
- it "should return array of resources" do
107
- gists = github.gists.starred
108
- gists.should be_an Array
109
- gists.should have(1).items
110
- end
111
-
112
- it "should be a mash type" do
113
- gists = github.gists.starred
114
- gists.first.should be_a Hashie::Mash
115
- end
116
-
117
- it "should get gist information" do
118
- gists = github.gists.starred
119
- gists.first.user.login.should == 'octocat'
120
- end
121
-
122
- it "should yield to a block" do
123
- github.gists.should_receive(:starred).and_yield('web')
124
- github.gists.starred() { |param| 'web' }
125
- end
126
- end
127
-
128
- context "resource not found" do
129
- before do
130
- stub_get("/gists/starred").
131
- to_return(:body => "", :status => [404, "Not Found"])
132
- end
133
-
134
- it "should return 404 with a message 'Not Found'" do
135
- expect {
136
- github.gists.starred
137
- }.to raise_error(Github::Error::NotFound)
138
- end
139
- end
140
- end # starred
141
-
142
- describe "#get" do
143
- it { github.gists.should respond_to :find }
144
-
145
- context "resource found" do
146
- before do
147
- stub_get("/gists/#{gist_id}").
148
- to_return(:body => fixture('gists/gist.json'), :status => 200,
149
- :headers => {:content_type => "application/json; charset=utf-8"})
150
- end
151
-
152
- it "should fail to get resource without gist id" do
153
- expect { github.gists.get nil }.to raise_error(ArgumentError)
154
- end
155
-
156
- it "should get the resource" do
157
- github.gists.get gist_id
158
- a_get("/gists/#{gist_id}").should have_been_made
159
- end
160
-
161
- it "should get gist information" do
162
- gist = github.gists.get gist_id
163
- gist.id.should eq gist_id
164
- gist.user.login.should == 'octocat'
165
- end
166
-
167
- it "should return mash" do
168
- gist = github.gists.get gist_id
169
- gist.should be_a Hashie::Mash
170
- end
171
- end
172
-
173
- context "resource not found" do
174
- before do
175
- stub_get("/gists/#{gist_id}").
176
- to_return(:body => fixture('gists/gist.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
177
- end
178
-
179
- it "should fail to retrive resource" do
180
- expect {
181
- github.gists.get gist_id
182
- }.to raise_error(Github::Error::NotFound)
183
- end
184
- end
185
- end # get
186
-
187
- describe "#create" do
188
- let(:inputs) {
189
- {
190
- "description" => "the description for this gist",
191
- "public" => true,
192
- "files" => {
193
- "file1.txt" => {
194
- "content" => "String file contents"
195
- }
196
- },
197
- }
198
- }
199
-
200
- context "resouce created" do
201
- before do
202
- stub_post("/gists").
203
- with(inputs).
204
- to_return(:body => fixture('gists/gist.json'),
205
- :status => 201,
206
- :headers => {:content_type => "application/json; charset=utf-8"})
207
- end
208
-
209
- it "should fail to create resource if 'files' input is missing" do
210
- expect {
211
- github.gists.create inputs.except('files')
212
- }.to raise_error(Github::Error::RequiredParams)
213
- end
214
-
215
- it "should fail to create resource if 'content' input is missing" do
216
- pending 'add validation for nested attributes'
217
- expect {
218
- github.gists.create inputs.except('content')
219
- }.to raise_error(Github::Error::RequiredParams)
220
- end
221
-
222
- it "should fail to create resource if 'public' input is missing" do
223
- expect {
224
- github.gists.create inputs.except('public')
225
- }.to raise_error(Github::Error::RequiredParams)
226
- end
227
-
228
- it "should create resource successfully" do
229
- github.gists.create inputs
230
- a_post("/gists").with(inputs).should have_been_made
231
- end
232
-
233
- it "should return the resource" do
234
- gist = github.gists.create inputs
235
- gist.should be_a Hashie::Mash
236
- end
237
-
238
- it "should get the gist information" do
239
- gist = github.gists.create inputs
240
- gist.user.login.should == 'octocat'
241
- end
242
- end
243
-
244
- context "failed to create resource" do
245
- before do
246
- stub_post("/gists").with(inputs).
247
- to_return(:body => fixture('gists/gist.json'),
248
- :status => 404,
249
- :headers => {:content_type => "application/json; charset=utf-8"})
250
- end
251
-
252
- it "should faile to retrieve resource" do
253
- expect {
254
- github.gists.create inputs
255
- }.to raise_error(Github::Error::NotFound)
256
- end
257
- end
258
- end # create
259
-
260
- describe "#edit" do
261
- let(:inputs) {
262
- {
263
- "description" => "the description for this gist",
264
- "files" => {
265
- "file1.txt" => {
266
- "content" => "updated file contents"
267
- },
268
- "old_name.txt" => {
269
- "filename" => "new_name.txt",
270
- "content" => "modified contents"
271
- },
272
- "new_file.txt" => {
273
- "content" => "a new file"
274
- },
275
- "delete_this_file.txt" => nil
276
- }
277
- }
278
- }
279
-
280
- context "resouce edited" do
281
- before do
282
- stub_patch("/gists/#{gist_id}").
283
- with(inputs).
284
- to_return(:body => fixture('gists/gist.json'),
285
- :status => 200,
286
- :headers => {:content_type => "application/json; charset=utf-8"})
287
- end
288
-
289
- it "should edit resource successfully" do
290
- github.gists.edit gist_id, inputs
291
- a_patch("/gists/#{gist_id}").with(inputs).should have_been_made
292
- end
293
-
294
- it "should return the resource" do
295
- gist = github.gists.edit gist_id, inputs
296
- gist.should be_a Hashie::Mash
297
- end
298
-
299
- it "should get the gist information" do
300
- gist = github.gists.edit gist_id, inputs
301
- gist.user.login.should == 'octocat'
302
- end
303
- end
304
-
305
- context "failed to edit resource" do
306
- before do
307
- stub_patch("/gists/#{gist_id}").with(inputs).
308
- to_return(:body => fixture('gists/gist.json'),
309
- :status => 404,
310
- :headers => {:content_type => "application/json; charset=utf-8"})
311
- end
312
-
313
- it "should fail to retrieve resource" do
314
- expect {
315
- github.gists.edit gist_id, inputs
316
- }.to raise_error(Github::Error::NotFound)
317
- end
318
- end
319
- end # edit
320
-
321
- context '#star' do
322
- before do
323
- stub_put("/gists/#{gist_id}/star").
324
- to_return(:body => '',
325
- :status => 204,
326
- :headers => {:content_type => "application/json; charset=utf-8"})
327
- end
328
-
329
- it "should raise error if gist id not present" do
330
- expect {
331
- github.gists.star nil
332
- }.to raise_error(ArgumentError)
333
- end
334
-
335
- it 'successfully stars a gist' do
336
- github.gists.star gist_id
337
- a_put("/gists/#{gist_id}/star").should have_been_made
338
- end
339
-
340
- it "should return 204 with a message 'Not Found'" do
341
- github.gists.star(gist_id).status.should be 204
342
- end
343
- end # star
344
-
345
- context '#unstar' do
346
- before do
347
- stub_delete("/gists/#{gist_id}/star").
348
- to_return(:body => '',
349
- :status => 204,
350
- :headers => {:content_type => "application/json; charset=utf-8"})
351
- end
352
-
353
- it "should raise error if gist id not present" do
354
- expect {
355
- github.gists.unstar nil
356
- }.to raise_error(ArgumentError)
357
- end
358
-
359
- it 'successfully stars a gist' do
360
- github.gists.unstar gist_id
361
- a_delete("/gists/#{gist_id}/star").should have_been_made
362
- end
363
-
364
- it "should return 204 with a message 'Not Found'" do
365
- github.gists.unstar(gist_id).status.should be 204
366
- end
367
- end # unstar
368
-
369
- context '#starred?' do
370
- before do
371
- stub_get("/gists/#{gist_id}/star").
372
- to_return(:body => '',
373
- :status => 204,
374
- :headers => {:content_type => "application/json; charset=utf-8"})
375
- end
376
-
377
- it 'should raise error if gist id not present' do
378
- expect {
379
- github.gists.starred? nil
380
- }.to raise_error(ArgumentError)
381
- end
382
-
383
- it 'should perform request' do
384
- github.gists.starred? gist_id
385
- a_get("/gists/#{gist_id}/star").should have_been_made
386
- end
387
-
388
- it 'should return true if gist is already starred' do
389
- github.gists.starred?(gist_id).should be_true
390
- end
391
-
392
- it 'should return false if gist is not starred' do
393
- stub_get("/gists/#{gist_id}/star").
394
- to_return(:body => '',
395
- :status => 404,
396
- :headers => {:content_type => "application/json; charset=utf-8"})
397
- github.gists.starred?(gist_id).should be_false
398
- end
399
- end # starred?
400
-
401
- context '#fork' do
402
- before do
403
- stub_post("/gists/#{gist_id}/fork").
404
- to_return(:body => fixture('gists/gist.json'),
405
- :status => 201,
406
- :headers => {:content_type => "application/json; charset=utf-8"})
407
- end
408
-
409
-
410
- it "should fail to fork gist without gist id" do
411
- expect { github.gists.fork(nil) }.to raise_error(ArgumentError)
412
- end
413
-
414
- it "should fork resource successfully" do
415
- github.gists.fork gist_id
416
- a_post("/gists/#{gist_id}/fork").should have_been_made
417
- end
418
-
419
- it "should return the resource" do
420
- gist = github.gists.fork gist_id
421
- gist.should be_a Hashie::Mash
422
- end
423
-
424
- it "should get the gist information" do
425
- gist = github.gists.fork gist_id
426
- gist.user.login.should == 'octocat'
427
- end
428
-
429
- it 'fails to retrieve resource' do
430
- stub_post("/gists/#{gist_id}/fork").
431
- to_return(:body => '',
432
- :status => 404,
433
- :headers => {:content_type => "application/json; charset=utf-8"})
434
- expect {
435
- github.gists.fork gist_id
436
- }.to raise_error(Github::Error::NotFound)
437
- end
438
- end # fork
439
-
440
- context "#delete" do
441
- before do
442
- stub_delete("/gists/#{gist_id}").
443
- to_return(:body => fixture('gists/gist.json'),
444
- :status => 204,
445
- :headers => {:content_type => "application/json; charset=utf-8"})
446
- end
447
-
448
- it 'should raise error if gist id not present' do
449
- expect {
450
- github.gists.delete nil
451
- }.to raise_error(ArgumentError)
452
- end
453
-
454
- it "should remove resource successfully" do
455
- github.gists.delete gist_id
456
- a_delete("/gists/#{gist_id}").should have_been_made
457
- end
458
-
459
- it "fails to delete resource" do
460
- stub_delete("/gists/#{gist_id}").
461
- to_return(:body => '',
462
- :status => 404,
463
- :headers => {:content_type => "application/json; charset=utf-8"})
464
- expect {
465
- github.gists.delete gist_id
466
- }.to raise_error(Github::Error::NotFound)
467
- end
468
- end # delete
469
-
470
- end # Github::Gists