slack-notifier 0.3.2 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62117fcfa420e6b62d6c4982c33b27b7ada1174a
4
- data.tar.gz: d475b9280f822a8f0eb67005b209a324b178891e
3
+ metadata.gz: 2f1ec45bf7b33fbafc47854195adbd58ef447820
4
+ data.tar.gz: 5f941b10ca31632805e4029cc432fee25dbe4de6
5
5
  SHA512:
6
- metadata.gz: 49d78c4b6cc439d904c41024958fb46aa529b654ce1ff7f4aba4351cfacbb82137a722817e989bd1228c75ad6143c9556347c61e9ef82947f56c51138728a1ba
7
- data.tar.gz: 0654d3a34c0223693109bed7badd4a99c4c162e140abe18995b8caa02c43b35ffe6789c2fb6ac538839dacae91531bfda298fbf4f596326450c373600a7ae2ec
6
+ metadata.gz: 2869813080b6254ae2bd41124ea10003b2a863721baa26710c4f86c455d15490f37f9660d7486465b11d3a0785c11e24b62f92200de4943ddbc42995a0f10fcb
7
+ data.tar.gz: 27943e0d35aedeee68ef5576419a4d4cbc79073f1f2ca21ce92a779eadc473f3f993dc289f10c232edb9f03e03d83069e043f678ad515a968eaa99f2c93f3aa5
@@ -27,6 +27,14 @@ module Slack
27
27
  HTTPPost.to endpoint, payload: payload.to_json
28
28
  end
29
29
 
30
+ def channel=(channel)
31
+ @channel = if channel.start_with?('#')
32
+ channel
33
+ else
34
+ "##{channel}"
35
+ end
36
+ end
37
+
30
38
  private
31
39
 
32
40
  def default_hook_name
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  class Notifier
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -1,15 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Slack::Notifier do
4
+ subject { described_class.new 'team', 'token' }
4
5
 
5
6
  describe "#initialize" do
6
7
  it "sets the given team" do
7
- subject = described_class.new 'team', 'token'
8
8
  expect( subject.team ).to eq 'team'
9
9
  end
10
10
 
11
11
  it "sets the given token" do
12
- subject = described_class.new 'team', 'token'
13
12
  expect( subject.token ).to eq 'token'
14
13
  end
15
14
 
@@ -37,22 +36,21 @@ describe Slack::Notifier do
37
36
  @endpoint_double = instance_double "URI::HTTP"
38
37
  allow( URI ).to receive(:parse)
39
38
  .and_return(@endpoint_double)
40
- @subject = described_class.new('team','token')
41
- @subject.channel = 'default'
39
+ subject.channel = '#default'
42
40
  end
43
41
 
44
42
  it "does not require a channel to ping" do
45
43
  expect{
46
- @subject.ping "the message"
44
+ subject.ping "the message"
47
45
  }.not_to raise_error
48
46
  end
49
47
 
50
48
  it "uses default channel" do
51
49
  expect( Slack::Notifier::HTTPPost ).to receive(:to)
52
50
  .with @endpoint_double,
53
- payload: '{"text":"the message","channel":"default"}'
51
+ payload: '{"text":"the message","channel":"#default"}'
54
52
 
55
- @subject.ping "the message"
53
+ subject.ping "the message"
56
54
  end
57
55
 
58
56
  it "allows override channel to be set" do
@@ -60,7 +58,7 @@ describe Slack::Notifier do
60
58
  .with @endpoint_double,
61
59
  payload: '{"text":"the message","channel":"new"}'
62
60
 
63
- @subject.ping "the message", channel: "new"
61
+ subject.ping "the message", channel: "new"
64
62
  end
65
63
 
66
64
  end
@@ -96,4 +94,15 @@ describe Slack::Notifier do
96
94
  end
97
95
  end
98
96
 
97
+ describe "#channel=" do
98
+ it "sets the given channel" do
99
+ subject.channel = "#foo"
100
+ expect( subject.channel ).to eql "#foo"
101
+ end
102
+
103
+ it "adds # prefix to channel" do
104
+ subject.channel = "foo"
105
+ expect( subject.channel ).to eql "#foo"
106
+ end
107
+ end
99
108
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: ' A slim ruby wrapper for posting to slack webhooks '
13
+ description: " A slim ruby wrapper for posting to slack webhooks "
14
14
  email:
15
15
  - stevenosloan@gmail.com
16
16
  executables: []
@@ -36,12 +36,12 @@ require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements: []
@@ -56,3 +56,4 @@ test_files:
56
56
  - spec/lib/slack-notifier/link_formatter_spec.rb
57
57
  - spec/lib/slack-notifier_spec.rb
58
58
  - spec/spec_helper.rb
59
+ has_rdoc: