mr_bump 0.2.0 → 0.2.1
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.
- checksums.yaml +8 -8
- data/lib/mr_bump/slack.rb +3 -1
- data/spec/slack_spec.rb +96 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
NThjNjNjNzI3OWZjNmNkMjIxOGI3NzAzY2NmZjNkYzU0NWRkYWY2Nw==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
YzA2OTc1NjMxZWE1MmFmYjQ4MzIzMDg1NjBkMzc3ZDA3NThmOWYzZg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
MWRhNjU0YmVjY2JjNDA1YzVjMzZkMmQwYzhlMDhlMmU4YmI2ZGY0M2NkYmIz
|
|
10
|
+
MzRhZDMyNTU3OTkwODk3M2Y2OTgzZDZhMTVkNDYwODExZjQyNTQ5N2NmZDYz
|
|
11
|
+
ZDA5Y2M5MTY4MWMyNjI4M2RkZmY0MWI0NGQ3YTg1Mzc3MTZhZTM=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
NTQ3MGU3MmI2N2Q0YmYxYTUyZWUwNjY3MDM4NjMxMGMxNDIxODY1NjcxOWQ4
|
|
14
|
+
ZjhiMGEyZDNhZjJiZWE1MjE0OTMyYTkwODYwMWFmZDIyZDk0YzQwYWNiMDdl
|
|
15
|
+
M2ZjN2E3YjdhMGMxZjU5MmQ0YjVkZTA0OGJiNjE0NTEzYzAwODg=
|
data/lib/mr_bump/slack.rb
CHANGED
|
@@ -6,12 +6,14 @@ require 'slack-notifier'
|
|
|
6
6
|
module MrBump
|
|
7
7
|
# This class uses a slack webhook to push notifications to slack
|
|
8
8
|
class Slack
|
|
9
|
+
attr_accessor :webhook, :username, :jira_url, :icon, :git
|
|
10
|
+
|
|
9
11
|
def initialize(git_config, opts)
|
|
10
12
|
raise ArgumentError, 'No Slack webhook found.' unless opts['webhook_url']
|
|
11
13
|
@webhook = opts['webhook_url']
|
|
12
14
|
@username = opts['username'] || 'Mr Bump'
|
|
13
15
|
@jira_url = opts['jira_url']
|
|
14
|
-
@icon =
|
|
16
|
+
@icon = Array(opts['icon']).sample
|
|
15
17
|
@git = git_config
|
|
16
18
|
end
|
|
17
19
|
|
data/spec/slack_spec.rb
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
4
|
+
|
|
5
|
+
require 'mr_bump/slack'
|
|
6
|
+
|
|
7
|
+
describe MrBump::Slack do
|
|
8
|
+
let(:config) do
|
|
9
|
+
{
|
|
10
|
+
'webhook_url' => webhook_url,
|
|
11
|
+
'username' => username,
|
|
12
|
+
'icon' => icons
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
let(:git_config) { {} }
|
|
16
|
+
let(:username) { nil }
|
|
17
|
+
let(:icons) { nil }
|
|
18
|
+
let(:webhook_url) { 'asdads' }
|
|
19
|
+
|
|
20
|
+
let(:slack) { described_class.new(git_config, config) }
|
|
21
|
+
|
|
22
|
+
context 'when not given a webhook url' do
|
|
23
|
+
let(:webhook_url) { nil }
|
|
24
|
+
it 'throws an error on construction' do
|
|
25
|
+
expect { slack }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'when given a valid config with no username' do
|
|
30
|
+
context 'when not given an icon' do
|
|
31
|
+
it 'defaults the name to "Mr Bump"' do
|
|
32
|
+
expect(slack.username).to eq('Mr Bump')
|
|
33
|
+
end
|
|
34
|
+
it 'has no icon' do
|
|
35
|
+
expect(slack.icon).to eq(nil)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'with an array of icons to use' do
|
|
40
|
+
let(:icons) { %w(a bc) }
|
|
41
|
+
|
|
42
|
+
it 'defaults the name to "Mr Bump"' do
|
|
43
|
+
expect(slack.username).to eq('Mr Bump')
|
|
44
|
+
end
|
|
45
|
+
it 'selects a single icon to use' do
|
|
46
|
+
expect(icons.include?(slack.icon))
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'with an single icon to use' do
|
|
51
|
+
let(:icons) { 'icon' }
|
|
52
|
+
|
|
53
|
+
it 'defaults the name to "Mr Bump"' do
|
|
54
|
+
expect(slack.username).to eq('Mr Bump')
|
|
55
|
+
end
|
|
56
|
+
it 'uses the single given icon' do
|
|
57
|
+
expect(slack.icon).to eq(icons)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context 'when given a valid config with a username' do
|
|
63
|
+
let(:username) { 'Sad Corporate Name' }
|
|
64
|
+
|
|
65
|
+
context 'when not given an icon' do
|
|
66
|
+
it 'uses the given username' do
|
|
67
|
+
expect(slack.username).to eq(username)
|
|
68
|
+
end
|
|
69
|
+
it 'has no icon' do
|
|
70
|
+
expect(slack.icon).to eq(nil)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context 'with an array of icons to use' do
|
|
75
|
+
let(:icons) { %w(a bc) }
|
|
76
|
+
|
|
77
|
+
it 'uses the given username' do
|
|
78
|
+
expect(slack.username).to eq(username)
|
|
79
|
+
end
|
|
80
|
+
it 'selects a single icon to use' do
|
|
81
|
+
expect(icons.include?(slack.icon))
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context 'with an single icon to use' do
|
|
86
|
+
let(:icons) { 'icon' }
|
|
87
|
+
|
|
88
|
+
it 'uses the given username' do
|
|
89
|
+
expect(slack.username).to eq(username)
|
|
90
|
+
end
|
|
91
|
+
it 'uses the single given icon' do
|
|
92
|
+
expect(slack.icon).to eq(icons)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mr_bump
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Fitzgerald
|
|
@@ -115,6 +115,7 @@ files:
|
|
|
115
115
|
- spec/config_spec.rb
|
|
116
116
|
- spec/git_config_spec.rb
|
|
117
117
|
- spec/mr_bump_spec.rb
|
|
118
|
+
- spec/slack_spec.rb
|
|
118
119
|
- spec/spec_helper.rb
|
|
119
120
|
homepage: https://github.com/xulaus/mr_bump
|
|
120
121
|
licenses:
|
|
@@ -145,4 +146,5 @@ test_files:
|
|
|
145
146
|
- spec/config_spec.rb
|
|
146
147
|
- spec/git_config_spec.rb
|
|
147
148
|
- spec/mr_bump_spec.rb
|
|
149
|
+
- spec/slack_spec.rb
|
|
148
150
|
- spec/spec_helper.rb
|