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
@@ -12,9 +12,8 @@ describe Github::GitData::Tags do
12
12
 
13
13
  it { described_class::VALID_TAG_PARAM_NAMES.should_not be_nil }
14
14
 
15
- describe "tag" do
16
- it { github.git_data.should respond_to :tag }
17
- it { github.git_data.should respond_to :get_tag }
15
+ describe "#get" do
16
+ it { github.git_data.tags.should respond_to :find }
18
17
 
19
18
  context "resource found" do
20
19
  before do
@@ -23,21 +22,23 @@ describe Github::GitData::Tags do
23
22
  end
24
23
 
25
24
  it "should fail to get resource without sha" do
26
- expect { github.git_data.tag(user, repo, nil)}.to raise_error(ArgumentError)
25
+ expect {
26
+ github.git_data.tags.get user, repo, nil
27
+ }.to raise_error(ArgumentError)
27
28
  end
28
29
 
29
30
  it "should get the resource" do
30
- github.git_data.tag user, repo, sha
31
+ github.git_data.tags.get user, repo, sha
31
32
  a_get("/repos/#{user}/#{repo}/git/tags/#{sha}").should have_been_made
32
33
  end
33
34
 
34
35
  it "should get tag information" do
35
- tag = github.git_data.tag user, repo, sha
36
+ tag = github.git_data.tags.get user, repo, sha
36
37
  tag.tag.should eql "v0.0.1"
37
38
  end
38
39
 
39
40
  it "should return mash" do
40
- tag = github.git_data.tag user, repo, sha
41
+ tag = github.git_data.tags.get user, repo, sha
41
42
  tag.should be_a Hashie::Mash
42
43
  end
43
44
  end
@@ -50,13 +51,13 @@ describe Github::GitData::Tags do
50
51
 
51
52
  it "should fail to retrive resource" do
52
53
  expect {
53
- github.git_data.tag user, repo, sha
54
+ github.git_data.tags.get user, repo, sha
54
55
  }.to raise_error(Github::Error::NotFound)
55
56
  end
56
57
  end
57
- end # tag
58
+ end # get
58
59
 
59
- describe "create_tag" do
60
+ describe "#create" do
60
61
  let(:inputs) {
61
62
  {
62
63
  "tag" => "v0.0.1",
@@ -83,17 +84,17 @@ describe Github::GitData::Tags do
83
84
  end
84
85
 
85
86
  it "should create resource successfully" do
86
- github.git_data.create_tag user, repo, inputs
87
+ github.git_data.tags.create user, repo, inputs
87
88
  a_post("/repos/#{user}/#{repo}/git/tags").with(inputs).should have_been_made
88
89
  end
89
90
 
90
91
  it "should return the resource" do
91
- tag = github.git_data.create_tag user, repo, inputs
92
+ tag = github.git_data.tags.create user, repo, inputs
92
93
  tag.should be_a Hashie::Mash
93
94
  end
94
95
 
95
96
  it "should get the tag information" do
96
- tag = github.git_data.create_tag user, repo, inputs
97
+ tag = github.git_data.tags.create user, repo, inputs
97
98
  tag.sha.should == sha
98
99
  end
99
100
  end
@@ -107,10 +108,10 @@ describe Github::GitData::Tags do
107
108
 
108
109
  it "should faile to retrieve resource" do
109
110
  expect {
110
- github.git_data.create_tag user, repo, inputs
111
+ github.git_data.tags.create user, repo, inputs
111
112
  }.to raise_error(Github::Error::NotFound)
112
113
  end
113
114
  end
114
- end # create_tag
115
+ end # create
115
116
 
116
117
  end # Github::GitData::Tags
@@ -12,9 +12,8 @@ describe Github::GitData::Trees do
12
12
 
13
13
  it { described_class::VALID_TREE_PARAM_NAMES.should_not be_nil }
14
14
 
15
- describe "tree" do
16
- it { github.git_data.should respond_to :tree }
17
- it { github.git_data.should respond_to :get_tree }
15
+ describe "#get" do
16
+ it { github.git_data.trees.should respond_to :find }
18
17
 
19
18
  context "non-resursive" do
20
19
  before do
@@ -23,21 +22,23 @@ describe Github::GitData::Trees do
23
22
  end
24
23
 
25
24
  it "should fail to get resource without sha" do
26
- expect { github.git_data.tree(user, repo, nil)}.to raise_error(ArgumentError)
25
+ expect {
26
+ github.git_data.trees.get user, repo, nil
27
+ }.to raise_error(ArgumentError)
27
28
  end
28
29
 
29
30
  it "should get the resource" do
30
- github.git_data.tree user, repo, sha
31
+ github.git_data.trees.get user, repo, sha
31
32
  a_get("/repos/#{user}/#{repo}/git/trees/#{sha}").should have_been_made
32
33
  end
33
34
 
34
35
  it "should get tree information" do
35
- tree = github.git_data.tree user, repo, sha
36
+ tree = github.git_data.trees.get user, repo, sha
36
37
  tree.sha.should eql sha
37
38
  end
38
39
 
39
40
  it "should return mash" do
40
- tree = github.git_data.tree user, repo, sha
41
+ tree = github.git_data.trees.get user, repo, sha
41
42
  tree.should be_a Hashie::Mash
42
43
  end
43
44
  end
@@ -49,17 +50,17 @@ describe Github::GitData::Trees do
49
50
  end
50
51
 
51
52
  it "should get the resource" do
52
- github.git_data.tree user, repo, sha, 'recursive' => true
53
+ github.git_data.trees.get user, repo, sha, 'recursive' => true
53
54
  a_get("/repos/#{user}/#{repo}/git/trees/#{sha}?recursive=1").should have_been_made
54
55
  end
55
56
 
56
57
  it "should get tree information" do
57
- tree = github.git_data.tree user, repo, sha, 'recursive' => true
58
+ tree = github.git_data.trees.get user, repo, sha, 'recursive' => true
58
59
  tree.sha.should eql sha
59
60
  end
60
61
 
61
62
  it "should return mash" do
62
- tree = github.git_data.tree user, repo, sha, 'recursive' => true
63
+ tree = github.git_data.trees.get user, repo, sha, 'recursive' => true
63
64
  tree.should be_a Hashie::Mash
64
65
  end
65
66
  end
@@ -72,13 +73,13 @@ describe Github::GitData::Trees do
72
73
 
73
74
  it "should fail to retrive resource" do
74
75
  expect {
75
- github.git_data.tree user, repo, sha
76
+ github.git_data.trees.get user, repo, sha
76
77
  }.to raise_error(Github::Error::NotFound)
77
78
  end
78
79
  end
79
- end # tree
80
+ end # get
80
81
 
81
- describe "create_tree" do
82
+ describe "#create" do
82
83
  let(:inputs) {
83
84
  {
84
85
  "tree" => [
@@ -101,22 +102,22 @@ describe Github::GitData::Trees do
101
102
 
102
103
  it "should fail to create resource if 'content' input is missing" do
103
104
  expect {
104
- github.git_data.create_tree user, repo, inputs.except('tree')
105
+ github.git_data.trees.create user, repo, inputs.except('tree')
105
106
  }.to raise_error(Github::Error::RequiredParams)
106
107
  end
107
108
 
108
109
  it "should create resource successfully" do
109
- github.git_data.create_tree user, repo, inputs
110
+ github.git_data.trees.create user, repo, inputs
110
111
  a_post("/repos/#{user}/#{repo}/git/trees").with(inputs).should have_been_made
111
112
  end
112
113
 
113
114
  it "should return the resource" do
114
- tree_sha = github.git_data.create_tree user, repo, inputs
115
+ tree_sha = github.git_data.trees.create user, repo, inputs
115
116
  tree_sha.should be_a Hashie::Mash
116
117
  end
117
118
 
118
119
  it "should get the tree information" do
119
- tree_sha = github.git_data.create_tree user, repo, inputs
120
+ tree_sha = github.git_data.trees.create user, repo, inputs
120
121
  tree_sha.sha.should == sha
121
122
  end
122
123
  end
@@ -130,10 +131,10 @@ describe Github::GitData::Trees do
130
131
 
131
132
  it "should faile to retrieve resource" do
132
133
  expect {
133
- github.git_data.create_tree user, repo, inputs
134
+ github.git_data.trees.create user, repo, inputs
134
135
  }.to raise_error(Github::Error::NotFound)
135
136
  end
136
137
  end
137
- end # create_tree
138
+ end # create
138
139
 
139
140
  end # Github::GitData::Trees
@@ -1,4 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Github::GitData do
4
- end
4
+
5
+ context 'access to apis' do
6
+ it { subject.blobs.should be_a Github::GitData::Blobs }
7
+ it { subject.commits.should be_a Github::GitData::Commits }
8
+ it { subject.references.should be_a Github::GitData::References }
9
+ it { subject.tags.should be_a Github::GitData::Tags }
10
+ it { subject.trees.should be_a Github::GitData::Trees }
11
+ end
12
+
13
+ end # Github::GitData
@@ -13,48 +13,49 @@ describe Github::Issues::Comments do
13
13
 
14
14
  it { described_class::VALID_ISSUE_COMMENT_PARAM_NAME.should_not be_nil }
15
15
 
16
- describe 'comments' do
17
-
18
- it { github.issues.should respond_to :comments }
19
- it { github.issues.should respond_to :issue_comments }
20
- it { github.issues.should respond_to :list_comments }
21
- it { github.issues.should respond_to :list_issue_comments }
16
+ describe '#list' do
17
+ it { github.issues.should respond_to :all }
22
18
 
23
19
  context "resource found" do
24
20
  before do
25
21
  stub_get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").
26
- to_return(:body => fixture('issues/comments.json'), :status => 200, :headers => {:content_type => "application/json; charset=utf-8"})
22
+ to_return(:body => fixture('issues/comments.json'),
23
+ :status => 200,
24
+ :headers => {:content_type => "application/json; charset=utf-8"})
27
25
  end
28
26
 
29
27
  it "should fail to get resource without username" do
30
- github.user, github.repo = nil, nil
31
- expect { github.issues.comments user, repo, nil }.to raise_error(ArgumentError)
28
+ expect {
29
+ github.issues.comments.list user, repo, nil
30
+ }.to raise_error(ArgumentError)
32
31
  end
33
32
 
34
33
  it "should get the resources" do
35
- github.issues.comments user, repo, issue_id
34
+ github.issues.comments.list user, repo, issue_id
36
35
  a_get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").should have_been_made
37
36
  end
38
37
 
39
38
  it "should return array of resources" do
40
- comments = github.issues.comments user, repo, issue_id
39
+ comments = github.issues.comments.list user, repo, issue_id
41
40
  comments.should be_an Array
42
41
  comments.should have(1).items
43
42
  end
44
43
 
45
44
  it "should be a mash type" do
46
- comments = github.issues.comments user, repo, issue_id
45
+ comments = github.issues.comments.list user, repo, issue_id
47
46
  comments.first.should be_a Hashie::Mash
48
47
  end
49
48
 
50
49
  it "should get issue comment information" do
51
- comments = github.issues.comments user, repo, issue_id
50
+ comments = github.issues.comments.list user, repo, issue_id
52
51
  comments.first.user.login.should == 'octocat'
53
52
  end
54
53
 
55
54
  it "should yield to a block" do
56
- github.issues.should_receive(:comments).with(user, repo, issue_id).and_yield('web')
57
- github.issues.comments(user, repo, issue_id) { |param| 'web' }.should == 'web'
55
+ github.issues.comments.should_receive(:list).
56
+ with(user, repo, issue_id).and_yield('web')
57
+ github.issues.comments.list(user, repo, issue_id) { |param| 'web' }.
58
+ should == 'web'
58
59
  end
59
60
  end
60
61
 
@@ -66,17 +67,14 @@ describe Github::Issues::Comments do
66
67
 
67
68
  it "should return 404 with a message 'Not Found'" do
68
69
  expect {
69
- github.issues.comments user, repo, issue_id
70
+ github.issues.comments.list user, repo, issue_id
70
71
  }.to raise_error(Github::Error::NotFound)
71
72
  end
72
73
  end
73
- end # comments
74
+ end # list
74
75
 
75
- describe "comment" do
76
-
77
- it { github.issues.should respond_to :comment }
78
- it { github.issues.should respond_to :issue_comment }
79
- it { github.issues.should respond_to :get_comment }
76
+ describe "#get" do
77
+ it { github.issues.comments.should respond_to :find }
80
78
 
81
79
  context "resource found" do
82
80
  before do
@@ -85,22 +83,24 @@ describe Github::Issues::Comments do
85
83
  end
86
84
 
87
85
  it "should fail to get resource without comment id" do
88
- expect { github.issues.comment(user, repo, nil)}.to raise_error(ArgumentError)
86
+ expect {
87
+ github.issues.comments.get user, repo, nil
88
+ }.to raise_error(ArgumentError)
89
89
  end
90
90
 
91
91
  it "should get the resource" do
92
- github.issues.comment user, repo, comment_id
92
+ github.issues.comments.get user, repo, comment_id
93
93
  a_get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").should have_been_made
94
94
  end
95
95
 
96
96
  it "should get comment information" do
97
- comment = github.issues.comment user, repo, comment_id
97
+ comment = github.issues.comments.get user, repo, comment_id
98
98
  comment.user.id.should == comment_id
99
99
  comment.user.login.should == 'octocat'
100
100
  end
101
101
 
102
102
  it "should return mash" do
103
- comment = github.issues.comment user, repo, comment_id
103
+ comment = github.issues.comments.get user, repo, comment_id
104
104
  comment.should be_a Hashie::Mash
105
105
  end
106
106
  end
@@ -108,136 +108,146 @@ describe Github::Issues::Comments do
108
108
  context "resource not found" do
109
109
  before do
110
110
  stub_get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
111
- to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
111
+ to_return(:body => fixture('issues/comment.json'),
112
+ :status => 404,
113
+ :headers => {:content_type => "application/json; charset=utf-8"})
112
114
  end
113
115
 
114
116
  it "should fail to retrive resource" do
115
117
  expect {
116
- github.issues.comment user, repo, comment_id
118
+ github.issues.comments.get user, repo, comment_id
117
119
  }.to raise_error(Github::Error::NotFound)
118
120
  end
119
121
  end
120
- end # comment
122
+ end # get
121
123
 
122
- describe "create_comment" do
124
+ describe "#create" do
123
125
  let(:issue_id) { 1 }
124
126
  let(:inputs) { { 'body' => 'a new comment' } }
125
127
 
126
- it { github.issues.should respond_to :create_comment }
127
- it { github.issues.should respond_to :create_issue_comment }
128
-
129
128
  context "resouce created" do
130
129
  before do
131
- stub_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").with(:body => inputs).
132
- to_return(:body => fixture('issues/comment.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
130
+ stub_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").
131
+ with(:body => inputs).
132
+ to_return(:body => fixture('issues/comment.json'),
133
+ :status => 201,
134
+ :headers => {:content_type => "application/json; charset=utf-8"})
133
135
  end
134
136
 
135
137
  it "should fail to create resource if 'body' input is missing" do
136
138
  expect {
137
- github.issues.create_comment user, repo, issue_id, inputs.except('body')
139
+ github.issues.comments.create user, repo, issue_id, inputs.except('body')
138
140
  }.to raise_error(Github::Error::RequiredParams)
139
141
  end
140
142
 
141
143
  it "should create resource successfully" do
142
- github.issues.create_comment user, repo, issue_id, inputs
143
- a_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").with(inputs).should have_been_made
144
+ github.issues.comments.create user, repo, issue_id, inputs
145
+ a_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").
146
+ with(inputs).should have_been_made
144
147
  end
145
148
 
146
149
  it "should return the resource" do
147
- comment = github.issues.create_comment user, repo, issue_id, inputs
150
+ comment = github.issues.comments.create user, repo, issue_id, inputs
148
151
  comment.should be_a Hashie::Mash
149
152
  end
150
153
 
151
154
  it "should get the comment information" do
152
- comment = github.issues.create_comment user, repo, issue_id, inputs
155
+ comment = github.issues.comments.create user, repo, issue_id, inputs
153
156
  comment.user.login.should == 'octocat'
154
157
  end
155
158
  end
156
159
 
157
160
  context "failed to create resource" do
158
161
  before do
159
- stub_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").with(inputs).
160
- to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
162
+ stub_post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments").
163
+ with(inputs).
164
+ to_return(:body => fixture('issues/comment.json'),
165
+ :status => 404,
166
+ :headers => {:content_type => "application/json; charset=utf-8"})
161
167
  end
162
168
 
163
169
  it "should fail to retrieve resource" do
164
170
  expect {
165
- github.issues.create_comment user, repo, issue_id, inputs
171
+ github.issues.comments.create user, repo, issue_id, inputs
166
172
  }.to raise_error(Github::Error::NotFound)
167
173
  end
168
174
  end
169
- end # create_comment
175
+ end # create
170
176
 
171
177
  describe "edit_comment" do
172
178
  let(:comment_id) { 1 }
173
179
  let(:inputs) { { 'body' => 'a new comment' } }
174
180
 
175
- it { github.issues.should respond_to :edit_comment }
176
- it { github.issues.should respond_to :edit_issue_comment }
177
-
178
181
  context "resouce edited" do
179
182
  before do
180
- stub_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").with(inputs).
181
- to_return(:body => fixture('issues/comment.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
183
+ stub_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
184
+ with(inputs).
185
+ to_return(:body => fixture('issues/comment.json'),
186
+ :status => 201,
187
+ :headers => {:content_type => "application/json; charset=utf-8"})
182
188
  end
183
189
 
184
190
  it "should fail to create resource if 'body' input is missing" do
185
191
  expect {
186
- github.issues.edit_comment user, repo, comment_id, inputs.except('body')
192
+ github.issues.comments.edit user, repo, comment_id, inputs.except('body')
187
193
  }.to raise_error(Github::Error::RequiredParams)
188
194
  end
189
195
 
190
196
  it "should create resource successfully" do
191
- github.issues.edit_comment user, repo, comment_id, inputs
192
- a_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").with(inputs).should have_been_made
197
+ github.issues.comments.edit user, repo, comment_id, inputs
198
+ a_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
199
+ with(inputs).should have_been_made
193
200
  end
194
201
 
195
202
  it "should return the resource" do
196
- comment = github.issues.edit_comment user, repo, comment_id, inputs
203
+ comment = github.issues.comments.edit user, repo, comment_id, inputs
197
204
  comment.should be_a Hashie::Mash
198
205
  end
199
206
 
200
207
  it "should get the comment information" do
201
- comment = github.issues.edit_comment user, repo, comment_id, inputs
208
+ comment = github.issues.comments.edit user, repo, comment_id, inputs
202
209
  comment.user.login.should == 'octocat'
203
210
  end
204
211
  end
205
212
 
206
213
  context "failed to create resource" do
207
214
  before do
208
- stub_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").with(inputs).
209
- to_return(:body => fixture('issues/comment.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
215
+ stub_patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
216
+ with(inputs).
217
+ to_return(:body => fixture('issues/comment.json'),
218
+ :status => 404,
219
+ :headers => {:content_type => "application/json; charset=utf-8"})
210
220
  end
211
221
 
212
222
  it "should fail to retrieve resource" do
213
223
  expect {
214
- github.issues.edit_comment user, repo, comment_id, inputs
224
+ github.issues.comments.edit user, repo, comment_id, inputs
215
225
  }.to raise_error(Github::Error::NotFound)
216
226
  end
217
227
  end
218
- end # edit_comment
228
+ end # edit
219
229
 
220
- describe "delete_comment" do
230
+ describe "#delete" do
221
231
  let(:comment_id) { 1 }
222
232
 
223
- it { github.issues.should respond_to :delete_comment }
224
- it { github.issues.should respond_to :delete_issue_comment }
225
-
226
233
  context "resouce deleted" do
227
234
  before do
228
235
  stub_delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
229
- to_return(:body => fixture('issues/comment.json'), :status => 204, :headers => {:content_type => "application/json; charset=utf-8"})
236
+ to_return(:body => fixture('issues/comment.json'),
237
+ :status => 204,
238
+ :headers => {:content_type => "application/json; charset=utf-8"})
230
239
  end
231
240
 
232
241
  it "should fail to delete resource if comment_id is missing" do
233
242
  expect {
234
- github.issues.delete_comment user, repo, nil
243
+ github.issues.comments.delete user, repo, nil
235
244
  }.to raise_error(ArgumentError)
236
245
  end
237
246
 
238
247
  it "should create resource successfully" do
239
- github.issues.delete_comment user, repo, comment_id
240
- a_delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").should have_been_made
248
+ github.issues.comments.delete user, repo, comment_id
249
+ a_delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}").
250
+ should have_been_made
241
251
  end
242
252
  end
243
253
 
@@ -249,10 +259,10 @@ describe Github::Issues::Comments do
249
259
 
250
260
  it "should fail to retrieve resource" do
251
261
  expect {
252
- github.issues.delete_comment user, repo, comment_id
262
+ github.issues.comments.delete user, repo, comment_id
253
263
  }.to raise_error(Github::Error::NotFound)
254
264
  end
255
265
  end
256
- end # delete_comment
266
+ end # delete
257
267
 
258
268
  end # Github::Issues::Comments