lita-github-commits 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +27 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/github_commits.rb +71 -0
- data/lib/lita-github-commits.rb +1 -0
- data/lita-github-commits.gemspec +23 -0
- data/spec/lita/handlers/github_commits_spec.rb +391 -0
- data/spec/spec_helper.rb +10 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6d9df5fc85994d6f7fec81c93c4d85c53ef74bc9
|
4
|
+
data.tar.gz: e15c9f03f760d278e0024fef164cfc383d9eb3c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d059244c6e0ee4b312c20e75ee0206ecae25dcd0745ac69f3b35065b0049abe962a4c206524a90d2c77da80c0e75832c6a2ec31dde4253b8c7655fc2ff71903d
|
7
|
+
data.tar.gz: 88d533d04f7373cae20fcbe5ca0c77d49b535de25cbaae5d57a2ccf2e1d83e972bb6fb4fd932aa8ca194c9a02f2b556353548a9bd416eec101ab3290fe2ade05
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 Mitch Dempsey
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# lita-github-commits
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/webdestroya/lita-github-commits.png)](https://travis-ci.org/webdestroya/lita-github-commits)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/webdestroya/lita-github-commits.png)](https://codeclimate.com/github/webdestroya/lita-github-commits)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/webdestroya/lita-github-commits/badge.png)](https://coveralls.io/r/webdestroya/lita-github-commits)
|
6
|
+
|
7
|
+
**lita-github-commits** is a handler for [Lita](https://github.com/jimmycuadra/lita) that listens for github commits and posts them in the channel.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add lita-github-commits to your Lita instance's Gemfile:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem "lita-github-commits"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
TODO: Describe any configuration attributes the plugin exposes.
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Describe the plugin's features and how to use them.
|
24
|
+
|
25
|
+
## License
|
26
|
+
|
27
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class GithubCommits < Handler
|
6
|
+
|
7
|
+
def self.default_config(config)
|
8
|
+
config.repos = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
http.post "/github-commits", :receive
|
12
|
+
|
13
|
+
def receive(request, response)
|
14
|
+
payload = parse_payload(request.params['payload']) or return
|
15
|
+
repo = get_repo(payload)
|
16
|
+
notify_rooms(repo, payload)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def parse_payload(payload)
|
22
|
+
MultiJson.load(payload)
|
23
|
+
rescue MultiJson::LoadError => e
|
24
|
+
Lita.logger.error("Could not parse JSON payload from Github: #{e.message}")
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
def notify_rooms(repo, payload)
|
29
|
+
rooms = rooms_for_repo(repo) or return
|
30
|
+
message = format_message(payload)
|
31
|
+
|
32
|
+
rooms.each do |room|
|
33
|
+
target = Source.new(nil, room)
|
34
|
+
robot.send_message(target, message)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_message(payload)
|
39
|
+
if payload['commits'].size > 0
|
40
|
+
"[GitHub] Got #{payload['commits'].size} new commits from #{payload['commits'].first['author']['name']} on #{payload['repository']['owner']['name']}/#{payload['repository']['name']}"
|
41
|
+
elsif payload['created']
|
42
|
+
"[GitHub] #{payload['pusher']['name']} created: #{payload['ref']}: #{payload['base_ref']}"
|
43
|
+
elsif payload['deleted']
|
44
|
+
"[GitHub] #{payload['pusher']['name']} deleted: #{payload['ref']}"
|
45
|
+
end
|
46
|
+
rescue
|
47
|
+
Lita.logger.warn "Error formatting message for #{repo} repo. Payload: #{payload}"
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
def rooms_for_repo(repo)
|
52
|
+
rooms = Lita.config.handlers.github_commits.repos[repo]
|
53
|
+
|
54
|
+
if rooms
|
55
|
+
Array(rooms)
|
56
|
+
else
|
57
|
+
Lita.logger.warn "Notification from GitHub Commits for unconfigured project: #{repo}"
|
58
|
+
return
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def get_repo(payload)
|
64
|
+
"#{payload['repository']['owner']['name']}/#{payload['repository']['name']}"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
Lita.register_handler(GithubCommits)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/github_commits"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-github-commits"
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.authors = ["Mitch Dempsey"]
|
5
|
+
spec.email = ["mrdempsey@gmail.com"]
|
6
|
+
spec.description = %q{A Lita handler that will display GitHub commit messages in the channel}
|
7
|
+
spec.summary = %q{A Lita handler that will display GitHub commit messages in the channel}
|
8
|
+
spec.homepage = "https://github.com/webdestroya/lita-github-commits"
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "lita", "~> 2.3"
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
spec.add_development_dependency "rake"
|
20
|
+
spec.add_development_dependency "rspec", ">= 2.14"
|
21
|
+
spec.add_development_dependency "simplecov"
|
22
|
+
spec.add_development_dependency "coveralls"
|
23
|
+
end
|
@@ -0,0 +1,391 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::GithubCommits, lita_handler: true do
|
4
|
+
it { routes_http(:post, "/github-commits").to(:receive) }
|
5
|
+
|
6
|
+
describe "#receive" do
|
7
|
+
|
8
|
+
let(:request) do
|
9
|
+
request = double("Rack::Request")
|
10
|
+
allow(request).to receive(:params).and_return(params)
|
11
|
+
request
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:response) { Rack::Response.new }
|
15
|
+
|
16
|
+
let(:params) { double("Hash") }
|
17
|
+
|
18
|
+
let(:valid_payload) do
|
19
|
+
<<-JSON.chomp
|
20
|
+
{
|
21
|
+
"after":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
22
|
+
"before":"17c497ccc7cca9c2f735aa07e9e3813060ce9a6a",
|
23
|
+
"commits":[
|
24
|
+
{
|
25
|
+
"added":[
|
26
|
+
|
27
|
+
],
|
28
|
+
"author":{
|
29
|
+
"email":"lolwut@noway.biz",
|
30
|
+
"name":"Garen Torikian",
|
31
|
+
"username":"octokitty"
|
32
|
+
},
|
33
|
+
"committer":{
|
34
|
+
"email":"lolwut@noway.biz",
|
35
|
+
"name":"Garen Torikian",
|
36
|
+
"username":"octokitty"
|
37
|
+
},
|
38
|
+
"distinct":true,
|
39
|
+
"id":"c441029cf673f84c8b7db52d0a5944ee5c52ff89",
|
40
|
+
"message":"Test",
|
41
|
+
"modified":[
|
42
|
+
"README.md"
|
43
|
+
],
|
44
|
+
"removed":[
|
45
|
+
|
46
|
+
],
|
47
|
+
"timestamp":"2013-02-22T13:50:07-08:00",
|
48
|
+
"url":"https://github.com/octokitty/testing/commit/c441029cf673f84c8b7db52d0a5944ee5c52ff89"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"added":[
|
52
|
+
|
53
|
+
],
|
54
|
+
"author":{
|
55
|
+
"email":"lolwut@noway.biz",
|
56
|
+
"name":"Garen Torikian",
|
57
|
+
"username":"octokitty"
|
58
|
+
},
|
59
|
+
"committer":{
|
60
|
+
"email":"lolwut@noway.biz",
|
61
|
+
"name":"Garen Torikian",
|
62
|
+
"username":"octokitty"
|
63
|
+
},
|
64
|
+
"distinct":true,
|
65
|
+
"id":"36c5f2243ed24de58284a96f2a643bed8c028658",
|
66
|
+
"message":"This is me testing the windows client.",
|
67
|
+
"modified":[
|
68
|
+
"README.md"
|
69
|
+
],
|
70
|
+
"removed":[
|
71
|
+
|
72
|
+
],
|
73
|
+
"timestamp":"2013-02-22T14:07:13-08:00",
|
74
|
+
"url":"https://github.com/octokitty/testing/commit/36c5f2243ed24de58284a96f2a643bed8c028658"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"added":[
|
78
|
+
"words/madame-bovary.txt"
|
79
|
+
],
|
80
|
+
"author":{
|
81
|
+
"email":"lolwut@noway.biz",
|
82
|
+
"name":"Garen Torikian",
|
83
|
+
"username":"octokitty"
|
84
|
+
},
|
85
|
+
"committer":{
|
86
|
+
"email":"lolwut@noway.biz",
|
87
|
+
"name":"Garen Torikian",
|
88
|
+
"username":"octokitty"
|
89
|
+
},
|
90
|
+
"distinct":true,
|
91
|
+
"id":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
92
|
+
"message":"Rename madame-bovary.txt to words/madame-bovary.txt",
|
93
|
+
"modified":[
|
94
|
+
|
95
|
+
],
|
96
|
+
"removed":[
|
97
|
+
"madame-bovary.txt"
|
98
|
+
],
|
99
|
+
"timestamp":"2013-03-12T08:14:29-07:00",
|
100
|
+
"url":"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb"
|
101
|
+
}
|
102
|
+
],
|
103
|
+
"compare":"https://github.com/octokitty/testing/compare/17c497ccc7cc...1481a2de7b2a",
|
104
|
+
"created":false,
|
105
|
+
"deleted":false,
|
106
|
+
"forced":false,
|
107
|
+
"head_commit":{
|
108
|
+
"added":[
|
109
|
+
"words/madame-bovary.txt"
|
110
|
+
],
|
111
|
+
"author":{
|
112
|
+
"email":"lolwut@noway.biz",
|
113
|
+
"name":"Garen Torikian",
|
114
|
+
"username":"octokitty"
|
115
|
+
},
|
116
|
+
"committer":{
|
117
|
+
"email":"lolwut@noway.biz",
|
118
|
+
"name":"Garen Torikian",
|
119
|
+
"username":"octokitty"
|
120
|
+
},
|
121
|
+
"distinct":true,
|
122
|
+
"id":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
123
|
+
"message":"Rename madame-bovary.txt to words/madame-bovary.txt",
|
124
|
+
"modified":[
|
125
|
+
|
126
|
+
],
|
127
|
+
"removed":[
|
128
|
+
"madame-bovary.txt"
|
129
|
+
],
|
130
|
+
"timestamp":"2013-03-12T08:14:29-07:00",
|
131
|
+
"url":"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb"
|
132
|
+
},
|
133
|
+
"pusher":{
|
134
|
+
"email":"lolwut@noway.biz",
|
135
|
+
"name":"Garen Torikian"
|
136
|
+
},
|
137
|
+
"ref":"refs/heads/master",
|
138
|
+
"repository":{
|
139
|
+
"created_at":1332977768,
|
140
|
+
"description":"",
|
141
|
+
"fork":false,
|
142
|
+
"forks":0,
|
143
|
+
"has_downloads":true,
|
144
|
+
"has_issues":true,
|
145
|
+
"has_wiki":true,
|
146
|
+
"homepage":"",
|
147
|
+
"id":3860742,
|
148
|
+
"language":"Ruby",
|
149
|
+
"master_branch":"master",
|
150
|
+
"name":"testing",
|
151
|
+
"open_issues":2,
|
152
|
+
"owner":{
|
153
|
+
"email":"lolwut@noway.biz",
|
154
|
+
"name":"octokitty"
|
155
|
+
},
|
156
|
+
"private":false,
|
157
|
+
"pushed_at":1363295520,
|
158
|
+
"size":2156,
|
159
|
+
"stargazers":1,
|
160
|
+
"url":"https://github.com/octokitty/testing",
|
161
|
+
"watchers":1
|
162
|
+
}
|
163
|
+
}
|
164
|
+
JSON
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
let(:created_payload) do
|
170
|
+
<<-JSON.chomp
|
171
|
+
{
|
172
|
+
"after":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
173
|
+
"before":"17c497ccc7cca9c2f735aa07e9e3813060ce9a6a",
|
174
|
+
"commits":[],
|
175
|
+
"compare":"https://github.com/octokitty/testing/compare/17c497ccc7cc...1481a2de7b2a",
|
176
|
+
"created":true,
|
177
|
+
"deleted":false,
|
178
|
+
"forced":false,
|
179
|
+
"head_commit":{
|
180
|
+
"added":[
|
181
|
+
"words/madame-bovary.txt"
|
182
|
+
],
|
183
|
+
"author":{
|
184
|
+
"email":"lolwut@noway.biz",
|
185
|
+
"name":"Garen Torikian",
|
186
|
+
"username":"octokitty"
|
187
|
+
},
|
188
|
+
"committer":{
|
189
|
+
"email":"lolwut@noway.biz",
|
190
|
+
"name":"Garen Torikian",
|
191
|
+
"username":"octokitty"
|
192
|
+
},
|
193
|
+
"distinct":true,
|
194
|
+
"id":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
195
|
+
"message":"Rename madame-bovary.txt to words/madame-bovary.txt",
|
196
|
+
"modified":[
|
197
|
+
|
198
|
+
],
|
199
|
+
"removed":[
|
200
|
+
"madame-bovary.txt"
|
201
|
+
],
|
202
|
+
"timestamp":"2013-03-12T08:14:29-07:00",
|
203
|
+
"url":"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb"
|
204
|
+
},
|
205
|
+
"pusher":{
|
206
|
+
"email":"lolwut@noway.biz",
|
207
|
+
"name":"Garen Torikian"
|
208
|
+
},
|
209
|
+
"ref":"refs/heads/master",
|
210
|
+
"repository":{
|
211
|
+
"created_at":1332977768,
|
212
|
+
"description":"",
|
213
|
+
"fork":false,
|
214
|
+
"forks":0,
|
215
|
+
"has_downloads":true,
|
216
|
+
"has_issues":true,
|
217
|
+
"has_wiki":true,
|
218
|
+
"homepage":"",
|
219
|
+
"id":3860742,
|
220
|
+
"language":"Ruby",
|
221
|
+
"master_branch":"master",
|
222
|
+
"name":"testing",
|
223
|
+
"open_issues":2,
|
224
|
+
"owner":{
|
225
|
+
"email":"lolwut@noway.biz",
|
226
|
+
"name":"octokitty"
|
227
|
+
},
|
228
|
+
"private":false,
|
229
|
+
"pushed_at":1363295520,
|
230
|
+
"size":2156,
|
231
|
+
"stargazers":1,
|
232
|
+
"url":"https://github.com/octokitty/testing",
|
233
|
+
"watchers":1
|
234
|
+
}
|
235
|
+
}
|
236
|
+
JSON
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
let(:deleted_payload) do
|
241
|
+
<<-JSON.chomp
|
242
|
+
{
|
243
|
+
"after":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
244
|
+
"before":"17c497ccc7cca9c2f735aa07e9e3813060ce9a6a",
|
245
|
+
"commits":[],
|
246
|
+
"compare":"https://github.com/octokitty/testing/compare/17c497ccc7cc...1481a2de7b2a",
|
247
|
+
"created":false,
|
248
|
+
"deleted":true,
|
249
|
+
"forced":false,
|
250
|
+
"head_commit":{
|
251
|
+
"added":[
|
252
|
+
"words/madame-bovary.txt"
|
253
|
+
],
|
254
|
+
"author":{
|
255
|
+
"email":"lolwut@noway.biz",
|
256
|
+
"name":"Garen Torikian",
|
257
|
+
"username":"octokitty"
|
258
|
+
},
|
259
|
+
"committer":{
|
260
|
+
"email":"lolwut@noway.biz",
|
261
|
+
"name":"Garen Torikian",
|
262
|
+
"username":"octokitty"
|
263
|
+
},
|
264
|
+
"distinct":true,
|
265
|
+
"id":"1481a2de7b2a7d02428ad93446ab166be7793fbb",
|
266
|
+
"message":"Rename madame-bovary.txt to words/madame-bovary.txt",
|
267
|
+
"modified":[
|
268
|
+
|
269
|
+
],
|
270
|
+
"removed":[
|
271
|
+
"madame-bovary.txt"
|
272
|
+
],
|
273
|
+
"timestamp":"2013-03-12T08:14:29-07:00",
|
274
|
+
"url":"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb"
|
275
|
+
},
|
276
|
+
"pusher":{
|
277
|
+
"email":"lolwut@noway.biz",
|
278
|
+
"name":"Garen Torikian"
|
279
|
+
},
|
280
|
+
"ref":"refs/heads/master",
|
281
|
+
"repository":{
|
282
|
+
"created_at":1332977768,
|
283
|
+
"description":"",
|
284
|
+
"fork":false,
|
285
|
+
"forks":0,
|
286
|
+
"has_downloads":true,
|
287
|
+
"has_issues":true,
|
288
|
+
"has_wiki":true,
|
289
|
+
"homepage":"",
|
290
|
+
"id":3860742,
|
291
|
+
"language":"Ruby",
|
292
|
+
"master_branch":"master",
|
293
|
+
"name":"testing",
|
294
|
+
"open_issues":2,
|
295
|
+
"owner":{
|
296
|
+
"email":"lolwut@noway.biz",
|
297
|
+
"name":"octokitty"
|
298
|
+
},
|
299
|
+
"private":false,
|
300
|
+
"pushed_at":1363295520,
|
301
|
+
"size":2156,
|
302
|
+
"stargazers":1,
|
303
|
+
"url":"https://github.com/octokitty/testing",
|
304
|
+
"watchers":1
|
305
|
+
}
|
306
|
+
}
|
307
|
+
JSON
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
context "request with commits" do
|
312
|
+
before do
|
313
|
+
Lita.config.handlers.github_commits.repos["octokitty/testing"] = "#baz"
|
314
|
+
allow(params).to receive(:[]).with("payload").and_return(valid_payload)
|
315
|
+
end
|
316
|
+
|
317
|
+
it "sends a notification message to the applicable rooms" do
|
318
|
+
expect(robot).to receive(:send_message) do |target, message|
|
319
|
+
expect(target.room).to eq("#baz")
|
320
|
+
expect(message).to include("[GitHub] Got")
|
321
|
+
end
|
322
|
+
subject.receive(request, response)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
context "create payload" do
|
329
|
+
before do
|
330
|
+
Lita.config.handlers.github_commits.repos["octokitty/testing"] = "#baz"
|
331
|
+
allow(params).to receive(:[]).with("payload").and_return(created_payload)
|
332
|
+
end
|
333
|
+
|
334
|
+
it "sends a notification message to the applicable rooms" do
|
335
|
+
expect(robot).to receive(:send_message) do |target, message|
|
336
|
+
expect(target.room).to eq("#baz")
|
337
|
+
expect(message).to include("[GitHub] Garen Torikian created")
|
338
|
+
end
|
339
|
+
subject.receive(request, response)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
|
344
|
+
context "delete payload" do
|
345
|
+
before do
|
346
|
+
Lita.config.handlers.github_commits.repos["octokitty/testing"] = "#baz"
|
347
|
+
allow(params).to receive(:[]).with("payload").and_return(deleted_payload)
|
348
|
+
end
|
349
|
+
|
350
|
+
it "sends a notification message to the applicable rooms" do
|
351
|
+
expect(robot).to receive(:send_message) do |target, message|
|
352
|
+
expect(target.room).to eq("#baz")
|
353
|
+
expect(message).to include("[GitHub] Garen Torikian deleted")
|
354
|
+
end
|
355
|
+
subject.receive(request, response)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
|
360
|
+
context "bad payload" do
|
361
|
+
before do
|
362
|
+
Lita.config.handlers.github_commits.repos["octokitty/testing"] = "#baz"
|
363
|
+
allow(params).to receive(:[]).with("payload").and_return("yaryary")
|
364
|
+
end
|
365
|
+
|
366
|
+
it "sends a notification message to the applicable rooms" do
|
367
|
+
expect(Lita.logger).to receive(:error) do |error|
|
368
|
+
expect(error).to include("Could not parse JSON payload from Github")
|
369
|
+
end
|
370
|
+
subject.receive(request, response)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
|
375
|
+
context "improper config" do
|
376
|
+
before do
|
377
|
+
allow(params).to receive(:[]).with("payload").and_return(deleted_payload)
|
378
|
+
end
|
379
|
+
|
380
|
+
it "sends a notification message to the applicable rooms" do
|
381
|
+
expect(Lita.logger).to receive(:warn) do |warning|
|
382
|
+
expect(warning).to include("Notification from GitHub Commits for unconfigured project")
|
383
|
+
end
|
384
|
+
subject.receive(request, response)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
|
389
|
+
end
|
390
|
+
|
391
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
require "coveralls"
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start { add_filter "/spec/" }
|
8
|
+
|
9
|
+
require "lita-github-commits"
|
10
|
+
require "lita/rspec"
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-github-commits
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mitch Dempsey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A Lita handler that will display GitHub commit messages in the channel
|
98
|
+
email:
|
99
|
+
- mrdempsey@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .travis.yml
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/lita-github-commits.rb
|
111
|
+
- lib/lita/handlers/github_commits.rb
|
112
|
+
- lita-github-commits.gemspec
|
113
|
+
- spec/lita/handlers/github_commits_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
homepage: https://github.com/webdestroya/lita-github-commits
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.0.7
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: A Lita handler that will display GitHub commit messages in the channel
|
139
|
+
test_files:
|
140
|
+
- spec/lita/handlers/github_commits_spec.rb
|
141
|
+
- spec/spec_helper.rb
|