github_api 0.4.11 → 0.5.0.rc1

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 (109) hide show
  1. data/README.md +76 -72
  2. data/features/cassettes/gists/starred.yml +48 -0
  3. data/features/cassettes/pagination/repos/commits/list.yml +193 -0
  4. data/features/cassettes/pagination/repos/commits/next.yml +183 -0
  5. data/features/cassettes/pagination/repos/diff/next.yml +45 -0
  6. data/features/cassettes/pagination/repos/list.yml +176 -0
  7. data/features/cassettes/pagination/repos/list/next.yml +222 -0
  8. data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
  9. data/features/cassettes/repos/list.yml +92 -0
  10. data/features/error_codes.feature +1 -1
  11. data/features/gists.feature +12 -3
  12. data/features/gists/comments.feature +3 -3
  13. data/features/github_api.feature +13 -2
  14. data/features/pagination.feature +40 -39
  15. data/features/repos.feature +2 -2
  16. data/features/step_definitions/common_steps.rb +12 -0
  17. data/features/step_definitions/github_api_steps.rb +12 -1
  18. data/lib/github_api.rb +1 -1
  19. data/lib/github_api/api.rb +4 -2
  20. data/lib/github_api/api_factory.rb +11 -5
  21. data/lib/github_api/authorizations.rb +23 -32
  22. data/lib/github_api/client.rb +1 -0
  23. data/lib/github_api/events.rb +38 -38
  24. data/lib/github_api/filter.rb +1 -1
  25. data/lib/github_api/gists.rb +47 -42
  26. data/lib/github_api/gists/comments.rb +77 -84
  27. data/lib/github_api/git_data.rb +25 -6
  28. data/lib/github_api/git_data/blobs.rb +48 -45
  29. data/lib/github_api/git_data/commits.rb +76 -73
  30. data/lib/github_api/git_data/references.rb +137 -118
  31. data/lib/github_api/git_data/tags.rb +74 -70
  32. data/lib/github_api/git_data/trees.rb +88 -85
  33. data/lib/github_api/issues.rb +43 -31
  34. data/lib/github_api/issues/comments.rb +116 -119
  35. data/lib/github_api/issues/events.rb +20 -19
  36. data/lib/github_api/issues/labels.rb +200 -197
  37. data/lib/github_api/issues/milestones.rb +137 -134
  38. data/lib/github_api/orgs.rb +27 -23
  39. data/lib/github_api/orgs/members.rb +105 -108
  40. data/lib/github_api/orgs/teams.rb +236 -237
  41. data/lib/github_api/paged_request.rb +1 -1
  42. data/lib/github_api/pull_requests.rb +40 -42
  43. data/lib/github_api/pull_requests/comments.rb +140 -143
  44. data/lib/github_api/repos.rb +101 -67
  45. data/lib/github_api/repos/collaborators.rb +64 -68
  46. data/lib/github_api/repos/commits.rb +50 -39
  47. data/lib/github_api/repos/downloads.rb +107 -110
  48. data/lib/github_api/repos/forks.rb +38 -39
  49. data/lib/github_api/repos/hooks.rb +161 -167
  50. data/lib/github_api/repos/keys.rb +86 -86
  51. data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
  52. data/lib/github_api/repos/watching.rb +80 -82
  53. data/lib/github_api/request.rb +5 -9
  54. data/lib/github_api/users.rb +26 -16
  55. data/lib/github_api/users/emails.rb +47 -47
  56. data/lib/github_api/users/followers.rb +85 -86
  57. data/lib/github_api/users/keys.rb +73 -75
  58. data/lib/github_api/validations.rb +25 -0
  59. data/lib/github_api/validations/format.rb +23 -0
  60. data/lib/github_api/validations/presence.rb +25 -0
  61. data/lib/github_api/validations/required.rb +21 -0
  62. data/lib/github_api/validations/token.rb +41 -0
  63. data/lib/github_api/version.rb +3 -3
  64. data/spec/fixtures/repos/commit_comparison.json +112 -0
  65. data/spec/github/api_factory_spec.rb +17 -1
  66. data/spec/github/authorizations_spec.rb +36 -34
  67. data/spec/github/gists/comments_spec.rb +39 -45
  68. data/spec/github/gists_spec.rb +50 -53
  69. data/spec/github/git_data/blobs_spec.rb +27 -20
  70. data/spec/github/git_data/commits_spec.rb +20 -19
  71. data/spec/github/git_data/references_spec.rb +83 -46
  72. data/spec/github/git_data/tags_spec.rb +16 -15
  73. data/spec/github/git_data/trees_spec.rb +20 -19
  74. data/spec/github/git_data_spec.rb +10 -1
  75. data/spec/github/issues/comments_spec.rb +78 -68
  76. data/spec/github/issues/events_spec.rb +42 -34
  77. data/spec/github/issues/labels_spec.rb +89 -101
  78. data/spec/github/issues/milestones_spec.rb +76 -54
  79. data/spec/github/issues_spec.rb +53 -57
  80. data/spec/github/orgs/members_spec.rb +64 -49
  81. data/spec/github/orgs/teams_spec.rb +112 -101
  82. data/spec/github/orgs_spec.rb +41 -31
  83. data/spec/github/paged_request_spec.rb +6 -5
  84. data/spec/github/pull_requests/comments_spec.rb +39 -44
  85. data/spec/github/pull_requests_spec.rb +32 -48
  86. data/spec/github/repos/collaborators_spec.rb +40 -29
  87. data/spec/github/repos/commits_spec.rb +108 -64
  88. data/spec/github/repos/downloads_spec.rb +46 -45
  89. data/spec/github/repos/forks_spec.rb +23 -24
  90. data/spec/github/repos/hooks_spec.rb +69 -71
  91. data/spec/github/repos/keys_spec.rb +39 -34
  92. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
  93. data/spec/github/repos/watching_spec.rb +31 -33
  94. data/spec/github/repos_spec.rb +74 -83
  95. data/spec/github/request_spec.rb +31 -2
  96. data/spec/github/users/emails_spec.rb +19 -17
  97. data/spec/github/users/followers_spec.rb +30 -28
  98. data/spec/github/users/keys_spec.rb +37 -33
  99. data/spec/github/users_spec.rb +124 -125
  100. data/spec/github/validations/format_spec.rb +42 -0
  101. data/spec/github/validations/presence_spec.rb +18 -0
  102. data/spec/github/validations/required_spec.rb +28 -0
  103. data/spec/github/validations/token_spec.rb +19 -0
  104. data/spec/github/validations_spec.rb +23 -0
  105. metadata +33 -10
  106. data/features/cassettes/pagination/repos.yml +0 -177
  107. data/features/cassettes/pagination/repos/next.yml +0 -177
  108. data/lib/github_api/validation.rb +0 -53
  109. data/spec/github/validation_spec.rb +0 -62
@@ -8,49 +8,49 @@ describe Github::Issues::Events do
8
8
  let(:repo) { 'github' }
9
9
  let(:issue_id) { 1 }
10
10
 
11
- after { github.user, github.repo, github.oauth_token = nil, nil, nil }
11
+ after { reset_authentication_for github }
12
12
 
13
- describe 'events' do
14
- it { github.issues.should respond_to :events }
15
- it { github.issues.should respond_to :list_events }
16
- it { github.issues.should respond_to :issue_events }
17
- it { github.issues.should respond_to :repo_events }
13
+ describe '#list' do
14
+ it { github.issues.comments.should respond_to :all }
18
15
 
19
16
  context 'without issue_id' do
20
17
  context "resource found" do
21
18
  before do
22
19
  stub_get("/repos/#{user}/#{repo}/issues/events").
23
- to_return(:body => fixture('issues/events.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
20
+ to_return(:body => fixture('issues/events.json'),
21
+ :status => 200,
22
+ :headers => {:content_type => "application/json; charset=utf-8"})
24
23
  end
25
24
 
26
25
  it "should fail to get resource without username" do
27
- expect { github.issues.events }.to raise_error(ArgumentError)
26
+ expect { github.issues.events.list }.to raise_error(ArgumentError)
28
27
  end
29
28
 
30
29
  it "should get the resources" do
31
- github.issues.events user, repo
30
+ github.issues.events.list user, repo
32
31
  a_get("/repos/#{user}/#{repo}/issues/events").should have_been_made
33
32
  end
34
33
 
35
34
  it "should return array of resources" do
36
- events = github.issues.events user, repo
35
+ events = github.issues.events.list user, repo
37
36
  events.should be_an Array
38
37
  events.should have(1).items
39
38
  end
40
39
 
41
40
  it "should be a mash type" do
42
- events = github.issues.events user, repo
41
+ events = github.issues.events.list user, repo
43
42
  events.first.should be_a Hashie::Mash
44
43
  end
45
44
 
46
45
  it "should get issue information" do
47
- events = github.issues.events user, repo
46
+ events = github.issues.events.list user, repo
48
47
  events.first.actor.login.should == 'octocat'
49
48
  end
50
49
 
51
50
  it "should yield to a block" do
52
- github.issues.should_receive(:events).with(user, repo).and_yield('web')
53
- github.issues.events(user, repo) { |param| 'web' }.should == 'web'
51
+ github.issues.events.should_receive(:list).
52
+ with(user, repo).and_yield('web')
53
+ github.issues.events.list(user, repo) { |param| 'web' }.should == 'web'
54
54
  end
55
55
  end
56
56
 
@@ -62,7 +62,7 @@ describe Github::Issues::Events do
62
62
 
63
63
  it "should return 404 with a message 'Not Found'" do
64
64
  expect {
65
- github.issues.events user, repo
65
+ github.issues.events.list user, repo
66
66
  }.to raise_error(Github::Error::NotFound)
67
67
  end
68
68
  end
@@ -76,63 +76,69 @@ describe Github::Issues::Events do
76
76
  end
77
77
 
78
78
  it "should get the resources" do
79
- github.issues.events user, repo, issue_id
79
+ github.issues.events.list user, repo, issue_id
80
80
  a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/events").should have_been_made
81
81
  end
82
82
 
83
83
  it "should return array of resources" do
84
- events = github.issues.events user, repo, issue_id
84
+ events = github.issues.events.list user, repo, issue_id
85
85
  events.should be_an Array
86
86
  events.should have(1).items
87
87
  end
88
88
 
89
89
  it "should be a mash type" do
90
- events = github.issues.events user, repo, issue_id
90
+ events = github.issues.events.list user, repo, issue_id
91
91
  events.first.should be_a Hashie::Mash
92
92
  end
93
93
 
94
94
  it "should get issue information" do
95
- events = github.issues.events user, repo, issue_id
95
+ events = github.issues.events.list user, repo, issue_id
96
96
  events.first.actor.login.should == 'octocat'
97
97
  end
98
98
 
99
99
  it "should yield to a block" do
100
- github.issues.should_receive(:events).with(user, repo, issue_id).and_yield('web')
101
- github.issues.events(user, repo, issue_id) { |param| 'web' }.should == 'web'
100
+ github.issues.events.should_receive(:list).
101
+ with(user, repo, issue_id).and_yield('web')
102
+ github.issues.events.list(user, repo, issue_id) { |param| 'web' }.
103
+ should == 'web'
102
104
  end
103
105
  end
104
106
  end # with issue_id
105
- end # events
107
+ end # list
106
108
 
107
- describe "event" do
109
+ describe "#get" do
108
110
  let(:event_id) { 1 }
109
111
 
110
- it { github.issues.should respond_to :event }
111
- it { github.issues.should respond_to :get_event }
112
+ it { github.issues.events.should respond_to :find }
112
113
 
113
114
  context "resource found" do
114
115
  before do
115
116
  stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
116
- to_return(:body => fixture('issues/event.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
117
+ to_return(:body => fixture('issues/event.json'),
118
+ :status => 200,
119
+ :headers => {:content_type => "application/json; charset=utf-8"})
117
120
  end
118
121
 
119
122
  it "should fail to get resource without event id" do
120
- expect { github.issues.event(user, repo, nil)}.to raise_error(ArgumentError)
123
+ expect {
124
+ github.issues.events.get user, repo, nil
125
+ }.to raise_error(ArgumentError)
121
126
  end
122
127
 
123
128
  it "should get the resource" do
124
- github.issues.event user, repo, event_id
125
- a_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").should have_been_made
129
+ github.issues.events.get user, repo, event_id
130
+ a_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
131
+ should have_been_made
126
132
  end
127
133
 
128
134
  it "should get event information" do
129
- event = github.issues.event user, repo, event_id
135
+ event = github.issues.events.get user, repo, event_id
130
136
  event.actor.id.should == event_id
131
137
  event.actor.login.should == 'octocat'
132
138
  end
133
139
 
134
140
  it "should return mash" do
135
- event = github.issues.event user, repo, event_id
141
+ event = github.issues.events.get user, repo, event_id
136
142
  event.should be_a Hashie::Mash
137
143
  end
138
144
  end
@@ -140,15 +146,17 @@ describe Github::Issues::Events do
140
146
  context "resource not found" do
141
147
  before do
142
148
  stub_get("/repos/#{user}/#{repo}/issues/events/#{event_id}").
143
- to_return(:body => fixture('issues/event.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
149
+ to_return(:body => fixture('issues/event.json'),
150
+ :status => 404,
151
+ :headers => {:content_type => "application/json; charset=utf-8"})
144
152
  end
145
153
 
146
154
  it "should fail to retrive resource" do
147
155
  expect {
148
- github.issues.event user, repo, event_id
156
+ github.issues.events.get user, repo, event_id
149
157
  }.to raise_error(Github::Error::NotFound)
150
158
  end
151
159
  end
152
- end # event
160
+ end # get
153
161
 
154
162
  end # Github::Issues:Events
@@ -4,14 +4,14 @@ describe Github::Issues::Labels do
4
4
  let(:github) { Github.new }
5
5
  let(:user) { 'peter-murach' }
6
6
  let(:repo) { 'github' }
7
+ let(:label_id) { 1 }
7
8
 
8
9
  after { github.user, github.repo, github.oauth_token = nil, nil, nil }
9
10
 
10
11
  it { described_class::VALID_LABEL_INPUTS.should_not be_nil }
11
12
 
12
- describe 'labels' do
13
- it { github.issues.should respond_to :labels }
14
- it { github.issues.should respond_to :list_labels }
13
+ describe '#list' do
14
+ it { github.issues.should respond_to :all }
15
15
 
16
16
  context "resource found" do
17
17
  before do
@@ -20,34 +20,35 @@ describe Github::Issues::Labels do
20
20
  end
21
21
 
22
22
  it "should fail to get resource without username" do
23
- github.user, github.repo = nil, nil
24
- expect { github.issues.labels nil, repo }.to raise_error(ArgumentError)
23
+ expect {
24
+ github.issues.labels.list nil, repo
25
+ }.to raise_error(ArgumentError)
25
26
  end
26
27
 
27
28
  it "should get the resources" do
28
- github.issues.labels user, repo
29
+ github.issues.labels.list user, repo
29
30
  a_get("/repos/#{user}/#{repo}/labels").should have_been_made
30
31
  end
31
32
 
32
33
  it "should return array of resources" do
33
- labels = github.issues.labels user, repo
34
+ labels = github.issues.labels.list user, repo
34
35
  labels.should be_an Array
35
36
  labels.should have(1).items
36
37
  end
37
38
 
38
39
  it "should be a mash type" do
39
- labels = github.issues.labels user, repo
40
+ labels = github.issues.labels.list user, repo
40
41
  labels.first.should be_a Hashie::Mash
41
42
  end
42
43
 
43
44
  it "should get issue information" do
44
- labels = github.issues.labels user, repo
45
+ labels = github.issues.labels.list user, repo
45
46
  labels.first.name.should == 'bug'
46
47
  end
47
48
 
48
49
  it "should yield to a block" do
49
- github.issues.should_receive(:labels).with(user, repo).and_yield('web')
50
- github.issues.labels(user, repo) { |param| 'web' }.should == 'web'
50
+ github.issues.labels.should_receive(:list).with(user, repo).and_yield('web')
51
+ github.issues.labels.list(user, repo) { |param| 'web' }.should == 'web'
51
52
  end
52
53
  end
53
54
 
@@ -59,18 +60,13 @@ describe Github::Issues::Labels do
59
60
 
60
61
  it "should return 404 with a message 'Not Found'" do
61
62
  expect {
62
- github.issues.labels user, repo
63
+ github.issues.labels.list user, repo
63
64
  }.to raise_error(Github::Error::NotFound)
64
65
  end
65
66
  end
66
- end # labels
67
-
68
- describe "label" do
69
- let(:label_id) { 1 }
70
-
71
- it { github.issues.should respond_to :label }
72
- it { github.issues.should respond_to :get_label }
67
+ end # list
73
68
 
69
+ describe "#find" do
74
70
  context "resource found" do
75
71
  before do
76
72
  stub_get("/repos/#{user}/#{repo}/labels/#{label_id}").
@@ -78,21 +74,23 @@ describe Github::Issues::Labels do
78
74
  end
79
75
 
80
76
  it "should fail to get resource without label id" do
81
- expect { github.issues.label(user, repo, nil)}.to raise_error(ArgumentError)
77
+ expect {
78
+ github.issues.labels.find(user, repo, nil)
79
+ }.to raise_error(ArgumentError)
82
80
  end
83
81
 
84
82
  it "should get the resource" do
85
- github.issues.label user, repo, label_id
83
+ github.issues.labels.find user, repo, label_id
86
84
  a_get("/repos/#{user}/#{repo}/labels/#{label_id}").should have_been_made
87
85
  end
88
86
 
89
87
  it "should get label information" do
90
- label = github.issues.label user, repo, label_id
88
+ label = github.issues.labels.find user, repo, label_id
91
89
  label.name.should == 'bug'
92
90
  end
93
91
 
94
92
  it "should return mash" do
95
- label = github.issues.label user, repo, label_id
93
+ label = github.issues.labels.find user, repo, label_id
96
94
  label.should be_a Hashie::Mash
97
95
  end
98
96
  end
@@ -105,13 +103,13 @@ describe Github::Issues::Labels do
105
103
 
106
104
  it "should fail to retrive resource" do
107
105
  expect {
108
- github.issues.label user, repo, label_id
106
+ github.issues.labels.find user, repo, label_id
109
107
  }.to raise_error(Github::Error::NotFound)
110
108
  end
111
109
  end
112
- end # label
110
+ end # find
113
111
 
114
- describe "create_label" do
112
+ describe "#create" do
115
113
  let(:inputs) {
116
114
  {
117
115
  "name" => "API",
@@ -127,28 +125,28 @@ describe Github::Issues::Labels do
127
125
 
128
126
  it "should fail to create resource if 'name' input is missing" do
129
127
  expect {
130
- github.issues.create_label user, repo, inputs.except('name')
128
+ github.issues.labels.create user, repo, inputs.except('name')
131
129
  }.to raise_error(Github::Error::RequiredParams)
132
130
  end
133
131
 
134
132
  it "should fail to create resource if 'color' input is missing" do
135
133
  expect {
136
- github.issues.create_label user, repo, inputs.except('color')
134
+ github.issues.labels.create user, repo, inputs.except('color')
137
135
  }.to raise_error(Github::Error::RequiredParams)
138
136
  end
139
137
 
140
138
  it "should create resource successfully" do
141
- github.issues.create_label user, repo, inputs
139
+ github.issues.labels.create user, repo, inputs
142
140
  a_post("/repos/#{user}/#{repo}/labels").with(inputs).should have_been_made
143
141
  end
144
142
 
145
143
  it "should return the resource" do
146
- label = github.issues.create_label user, repo, inputs
144
+ label = github.issues.labels.create user, repo, inputs
147
145
  label.should be_a Hashie::Mash
148
146
  end
149
147
 
150
148
  it "should get the label information" do
151
- label = github.issues.create_label user, repo, inputs
149
+ label = github.issues.labels.create user, repo, inputs
152
150
  label.name.should == 'bug'
153
151
  end
154
152
  end
@@ -157,19 +155,17 @@ describe Github::Issues::Labels do
157
155
  before do
158
156
  stub_post("/repos/#{user}/#{repo}/labels").with(inputs).
159
157
  to_return(:body => fixture('issues/label.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
160
-
161
158
  end
162
159
 
163
160
  it "should faile to retrieve resource" do
164
161
  expect {
165
- github.issues.create_label user, repo, inputs
162
+ github.issues.labels.create user, repo, inputs
166
163
  }.to raise_error(Github::Error::NotFound)
167
164
  end
168
165
  end
169
- end # create_label
166
+ end # create
170
167
 
171
- describe "update_label" do
172
- let(:label_id) { 1 }
168
+ describe "#update" do
173
169
  let(:inputs) {
174
170
  {
175
171
  "name" => "API",
@@ -185,28 +181,28 @@ describe Github::Issues::Labels do
185
181
 
186
182
  it "should fail to create resource if 'name' input is missing" do
187
183
  expect {
188
- github.issues.update_label user, repo, label_id, inputs.except('name')
184
+ github.issues.labels.update user, repo, label_id, inputs.except('name')
189
185
  }.to raise_error(Github::Error::RequiredParams)
190
186
  end
191
187
 
192
188
  it "should fail to create resource if 'color' input is missing" do
193
189
  expect {
194
- github.issues.update_label user, repo, label_id, inputs.except('color')
190
+ github.issues.labels.update user, repo, label_id, inputs.except('color')
195
191
  }.to raise_error(Github::Error::RequiredParams)
196
192
  end
197
193
 
198
194
  it "should update resource successfully" do
199
- github.issues.update_label user, repo, label_id, inputs
195
+ github.issues.labels.update user, repo, label_id, inputs
200
196
  a_patch("/repos/#{user}/#{repo}/labels/#{label_id}").with(inputs).should have_been_made
201
197
  end
202
198
 
203
199
  it "should return the resource" do
204
- label = github.issues.update_label user, repo, label_id, inputs
200
+ label = github.issues.labels.update user, repo, label_id, inputs
205
201
  label.should be_a Hashie::Mash
206
202
  end
207
203
 
208
204
  it "should get the label information" do
209
- label = github.issues.update_label user, repo, label_id, inputs
205
+ label = github.issues.labels.update user, repo, label_id, inputs
210
206
  label.name.should == 'bug'
211
207
  end
212
208
  end
@@ -215,20 +211,17 @@ describe Github::Issues::Labels do
215
211
  before do
216
212
  stub_patch("/repos/#{user}/#{repo}/labels/#{label_id}").with(inputs).
217
213
  to_return(:body => fixture('issues/label.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
218
-
219
214
  end
220
215
 
221
216
  it "should faile to retrieve resource" do
222
217
  expect {
223
- github.issues.update_label user, repo, label_id, inputs
218
+ github.issues.labels.update user, repo, label_id, inputs
224
219
  }.to raise_error(Github::Error::NotFound)
225
220
  end
226
221
  end
227
- end # update_label
228
-
229
- describe "delete_label" do
230
- let(:label_id) { 1 }
222
+ end # update
231
223
 
224
+ describe "#delete" do
232
225
  context "resouce removed" do
233
226
  before do
234
227
  stub_delete("/repos/#{user}/#{repo}/labels/#{label_id}").
@@ -236,17 +229,17 @@ describe Github::Issues::Labels do
236
229
  end
237
230
 
238
231
  it "should remove resource successfully" do
239
- github.issues.delete_label user, repo, label_id
232
+ github.issues.labels.delete user, repo, label_id
240
233
  a_delete("/repos/#{user}/#{repo}/labels/#{label_id}").should have_been_made
241
234
  end
242
235
 
243
236
  it "should return the resource" do
244
- label = github.issues.delete_label user, repo, label_id
237
+ label = github.issues.labels.delete user, repo, label_id
245
238
  label.should be_a Hashie::Mash
246
239
  end
247
240
 
248
241
  it "should get the label information" do
249
- label = github.issues.delete_label user, repo, label_id
242
+ label = github.issues.labels.delete user, repo, label_id
250
243
  label.name.should == 'bug'
251
244
  end
252
245
  end
@@ -259,18 +252,15 @@ describe Github::Issues::Labels do
259
252
 
260
253
  it "should faile to retrieve resource" do
261
254
  expect {
262
- github.issues.delete_label user, repo, label_id
255
+ github.issues.labels.delete user, repo, label_id
263
256
  }.to raise_error(Github::Error::NotFound)
264
257
  end
265
258
  end
266
- end # delete_label
259
+ end # delete
267
260
 
268
- describe 'labels_for' do
261
+ describe '#issue' do
269
262
  let(:issue_id) { 1 }
270
263
 
271
- it { github.issues.should respond_to :labels_for }
272
- it { github.issues.should respond_to :issue_labels }
273
-
274
264
  context "resource found" do
275
265
  before do
276
266
  stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
@@ -279,35 +269,36 @@ describe Github::Issues::Labels do
279
269
 
280
270
  it "should fail to get resource without issue_id" do
281
271
  expect {
282
- github.issues.labels_for user, repo, nil
272
+ github.issues.labels.issue user, repo, nil
283
273
  }.to raise_error(ArgumentError)
284
274
  end
285
275
 
286
276
  it "should get the resources" do
287
- github.issues.labels_for user, repo, issue_id
277
+ github.issues.labels.issue user, repo, issue_id
288
278
  a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").
289
279
  should have_been_made
290
280
  end
291
281
 
292
282
  it "should return array of resources" do
293
- labels = github.issues.labels_for user, repo, issue_id
283
+ labels = github.issues.labels.issue user, repo, issue_id
294
284
  labels.should be_an Array
295
285
  labels.should have(1).items
296
286
  end
297
287
 
298
288
  it "should be a mash type" do
299
- labels = github.issues.labels_for user, repo, issue_id
289
+ labels = github.issues.labels.issue user, repo, issue_id
300
290
  labels.first.should be_a Hashie::Mash
301
291
  end
302
292
 
303
293
  it "should get issue information" do
304
- labels = github.issues.labels_for user, repo, issue_id
294
+ labels = github.issues.labels.issue user, repo, issue_id
305
295
  labels.first.name.should == 'bug'
306
296
  end
307
297
 
308
298
  it "should yield to a block" do
309
- github.issues.should_receive(:labels_for).with(user, repo, issue_id).and_yield('web')
310
- github.issues.labels_for(user, repo, issue_id) { |param| 'web' }.should == 'web'
299
+ github.issues.labels.should_receive(:issue).
300
+ with(user, repo, issue_id).and_yield('web')
301
+ github.issues.labels.issue(user, repo, issue_id) { |param| 'web' }.should == 'web'
311
302
  end
312
303
  end
313
304
 
@@ -319,13 +310,13 @@ describe Github::Issues::Labels do
319
310
 
320
311
  it "should return 404 with a message 'Not Found'" do
321
312
  expect {
322
- github.issues.labels_for user, repo, issue_id
313
+ github.issues.labels.issue user, repo, issue_id
323
314
  }.to raise_error(Github::Error::NotFound)
324
315
  end
325
316
  end
326
- end # labels_for
317
+ end # issue
327
318
 
328
- describe "add_labels" do
319
+ describe "#add" do
329
320
  let(:issue_id) { 1 }
330
321
  let(:labels) { "Label 1" }
331
322
 
@@ -337,22 +328,22 @@ describe Github::Issues::Labels do
337
328
 
338
329
  it "should fail to add labels if issue-id is missing" do
339
330
  expect {
340
- github.issues.add_labels user, repo, nil, labels
331
+ github.issues.labels.add user, repo, nil, labels
341
332
  }.to raise_error(ArgumentError)
342
333
  end
343
334
 
344
335
  it "should create resource successfully" do
345
- github.issues.add_labels user, repo, issue_id, labels
336
+ github.issues.labels.add user, repo, issue_id, labels
346
337
  a_post("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
347
338
  end
348
339
 
349
340
  it "should return the resource" do
350
- labels = github.issues.add_labels user, repo, issue_id, labels
341
+ labels = github.issues.labels.add user, repo, issue_id, labels
351
342
  labels.first.should be_a Hashie::Mash
352
343
  end
353
344
 
354
345
  it "should get the label information" do
355
- labels = github.issues.add_labels user, repo, issue_id, labels
346
+ labels = github.issues.labels.add user, repo, issue_id, labels
356
347
  labels.first.name.should == 'bug'
357
348
  end
358
349
  end
@@ -366,13 +357,13 @@ describe Github::Issues::Labels do
366
357
 
367
358
  it "should fail to retrieve resource" do
368
359
  expect {
369
- github.issues.add_labels user, repo, issue_id, labels
360
+ github.issues.labels.add user, repo, issue_id, labels
370
361
  }.to raise_error(Github::Error::NotFound)
371
362
  end
372
363
  end
373
- end # add_labels
364
+ end # add
374
365
 
375
- describe "remove_label" do
366
+ describe "#remove" do
376
367
  let(:issue_id) { 1 }
377
368
  let(:label_id) { 1 }
378
369
 
@@ -384,22 +375,22 @@ describe Github::Issues::Labels do
384
375
 
385
376
  it "should throw exception if issue-id not present" do
386
377
  expect {
387
- github.issues.remove_label user, repo, nil
378
+ github.issues.labels.remove user, repo, nil
388
379
  }.to raise_error(ArgumentError)
389
380
  end
390
381
 
391
382
  it "should remove label successfully" do
392
- github.issues.remove_label user, repo, issue_id, label_id
383
+ github.issues.labels.remove user, repo, issue_id, label_id
393
384
  a_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}").should have_been_made
394
385
  end
395
386
 
396
387
  it "should return the resource" do
397
- labels = github.issues.remove_label user, repo, issue_id, label_id
388
+ labels = github.issues.labels.remove user, repo, issue_id, label_id
398
389
  labels.first.should be_a Hashie::Mash
399
390
  end
400
391
 
401
392
  it "should get the label information" do
402
- labels = github.issues.remove_label user, repo, issue_id, label_id
393
+ labels = github.issues.labels.remove user, repo, issue_id, label_id
403
394
  labels.first.name.should == 'bug'
404
395
  end
405
396
  end
@@ -411,7 +402,7 @@ describe Github::Issues::Labels do
411
402
  end
412
403
 
413
404
  it "should remove labels successfully" do
414
- github.issues.remove_label user, repo, issue_id
405
+ github.issues.labels.remove user, repo, issue_id
415
406
  a_delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
416
407
  end
417
408
  end
@@ -424,13 +415,13 @@ describe Github::Issues::Labels do
424
415
 
425
416
  it "should faile to retrieve resource" do
426
417
  expect {
427
- github.issues.remove_label user, repo, issue_id, label_id
418
+ github.issues.labels.remove user, repo, issue_id, label_id
428
419
  }.to raise_error(Github::Error::NotFound)
429
420
  end
430
421
  end
431
- end # remove_label
422
+ end # remove
432
423
 
433
- describe "replace_labels" do
424
+ describe "#replace" do
434
425
  let(:issue_id) { 1 }
435
426
  let(:labels) { "Label 1" }
436
427
 
@@ -442,22 +433,22 @@ describe Github::Issues::Labels do
442
433
 
443
434
  it "should fail to add labels if issue-id is missing" do
444
435
  expect {
445
- github.issues.replace_labels user, repo, nil, labels
436
+ github.issues.labels.replace user, repo, nil, labels
446
437
  }.to raise_error(ArgumentError)
447
438
  end
448
439
 
449
440
  it "should create resource successfully" do
450
- github.issues.replace_labels user, repo, issue_id, labels
441
+ github.issues.labels.replace user, repo, issue_id, labels
451
442
  a_put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels").should have_been_made
452
443
  end
453
444
 
454
445
  it "should return the resource" do
455
- labels = github.issues.replace_labels user, repo, issue_id, labels
446
+ labels = github.issues.labels.replace user, repo, issue_id, labels
456
447
  labels.first.should be_a Hashie::Mash
457
448
  end
458
449
 
459
450
  it "should get the label information" do
460
- labels = github.issues.replace_labels user, repo, issue_id, labels
451
+ labels = github.issues.labels.replace user, repo, issue_id, labels
461
452
  labels.first.name.should == 'bug'
462
453
  end
463
454
  end
@@ -471,19 +462,15 @@ describe Github::Issues::Labels do
471
462
 
472
463
  it "should fail to retrieve resource" do
473
464
  expect {
474
- github.issues.replace_labels user, repo, issue_id, labels
465
+ github.issues.labels.replace user, repo, issue_id, labels
475
466
  }.to raise_error(Github::Error::NotFound)
476
467
  end
477
468
  end
478
- end # add_labels
469
+ end # replace
479
470
 
480
- describe 'milestone_labels' do
471
+ describe '#milestone' do
481
472
  let(:milestone_id) { 1 }
482
473
 
483
- it { github.issues.should respond_to :milestone_labels }
484
- it { github.issues.should respond_to :milestone_issues_labels }
485
- it { github.issues.should respond_to :list_milestone_labels }
486
-
487
474
  context "resource found" do
488
475
  before do
489
476
  stub_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels").
@@ -492,34 +479,35 @@ describe Github::Issues::Labels do
492
479
 
493
480
  it "should throw exception if milestone-id not present" do
494
481
  expect {
495
- github.issues.remove_label user, repo, nil
482
+ github.issues.labels.milestone user, repo, nil
496
483
  }.to raise_error(ArgumentError)
497
484
  end
498
485
 
499
486
  it "should get the resources" do
500
- github.issues.milestone_labels user, repo, milestone_id
487
+ github.issues.labels.milestone user, repo, milestone_id
501
488
  a_get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels").should have_been_made
502
489
  end
503
490
 
504
491
  it "should return array of resources" do
505
- labels = github.issues.milestone_labels user, repo, milestone_id
492
+ labels = github.issues.labels.milestone user, repo, milestone_id
506
493
  labels.should be_an Array
507
494
  labels.should have(1).items
508
495
  end
509
496
 
510
497
  it "should be a mash type" do
511
- labels = github.issues.milestone_labels user, repo, milestone_id
498
+ labels = github.issues.labels.milestone user, repo, milestone_id
512
499
  labels.first.should be_a Hashie::Mash
513
500
  end
514
501
 
515
502
  it "should get issue information" do
516
- labels = github.issues.milestone_labels user, repo, milestone_id
503
+ labels = github.issues.labels.milestone user, repo, milestone_id
517
504
  labels.first.name.should == 'bug'
518
505
  end
519
506
 
520
507
  it "should yield to a block" do
521
- github.issues.should_receive(:milestone_labels).with(user, repo, milestone_id).and_yield('web')
522
- github.issues.milestone_labels(user, repo, milestone_id) { |param| 'web' }.should == 'web'
508
+ github.issues.labels.should_receive(:milestone).
509
+ with(user, repo, milestone_id).and_yield('web')
510
+ github.issues.labels.milestone(user, repo, milestone_id) { |param| 'web' }.should == 'web'
523
511
  end
524
512
  end
525
513
 
@@ -531,10 +519,10 @@ describe Github::Issues::Labels do
531
519
 
532
520
  it "should return 404 with a message 'Not Found'" do
533
521
  expect {
534
- github.issues.milestone_labels user, repo, milestone_id
522
+ github.issues.labels.milestone user, repo, milestone_id
535
523
  }.to raise_error(Github::Error::NotFound)
536
524
  end
537
525
  end
538
- end # milestone_labels
526
+ end # milestone
539
527
 
540
528
  end # Github::Issues::Labels