slack-notifier 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 343978628e7a8085818befad991f0c3629527237
4
- data.tar.gz: c05543a0c0385f954bd79bd64def1743b2d8e346
3
+ metadata.gz: 4c25d21ad14b892d64f85243a8efbe8ae44b0afe
4
+ data.tar.gz: d503745569e2e3c73b68d3f58103b37bd47f3e27
5
5
  SHA512:
6
- metadata.gz: cb4ab2e7781936a0d9829e5426848a89832063f2e9791ab5531f89df244acfc29d01b814ac8e2f6d7d36797d7229f8d1acdf2e8b27992a13255980f29bf66d06
7
- data.tar.gz: c21154be148aa4e44d432f3006229989e29a889b4302de2f7b5170a15e481150fe733809ea98ec5971eca428ce70fe3a2599e88fb490bd1e8ecb39de1d17dfbb
6
+ metadata.gz: 8eb400bf7af214c7d85e066948fd76e412513d3f19b703c039fd91c99ed9275510cb1111d157463021c7d2166e4eafb232465ca091aef6b1ebc4daf482c8617b
7
+ data.tar.gz: 659801d155a85f5ade8c509be7fa70019943801fb5bb173696ff5d64ce7feffb944eeddb1d2ae8932165f799865a0ad0c21a57eb1732a5f54ee77b45fc023af8
@@ -1,4 +1,5 @@
1
- require 'httparty'
1
+ require 'net/http'
2
+ require 'uri'
2
3
  require 'json'
3
4
 
4
5
  require_relative 'slack-notifier/link_formatter'
@@ -25,7 +26,7 @@ module Slack
25
26
  raise ArgumentError, "You must set a channel"
26
27
  end
27
28
 
28
- HTTParty.post( endpoint, body: "payload=#{payload.to_json}" )
29
+ Net::HTTP.post_form endpoint, payload: payload.to_json
29
30
  end
30
31
 
31
32
  private
@@ -38,7 +39,7 @@ module Slack
38
39
  end
39
40
 
40
41
  def endpoint
41
- "https://#{team}.slack.com/services/hooks/incoming-webhook?token=#{token}"
42
+ URI.parse "https://#{team}.slack.com/services/hooks/incoming-webhook?token=#{token}"
42
43
  end
43
44
 
44
45
  end
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  class Notifier
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -15,8 +15,15 @@ describe Slack::Notifier do
15
15
  end
16
16
 
17
17
  describe "#ping" do
18
+ before :each do
19
+ allow( Net::HTTP ).to receive(:post_form)
20
+ @endpoint_double = instance_double "URI::HTTP"
21
+ allow( URI ).to receive(:parse)
22
+ .with("https://team.slack.com/services/hooks/incoming-webhook?token=token")
23
+ .and_return(@endpoint_double)
24
+ end
25
+
18
26
  it "passes the message through LinkFormatter" do
19
- allow( HTTParty ).to receive(:post)
20
27
  expect( Slack::Notifier::LinkFormatter ).to receive(:format)
21
28
  .with("the message")
22
29
 
@@ -24,8 +31,6 @@ describe Slack::Notifier do
24
31
  end
25
32
 
26
33
  it "requires a channel to be set" do
27
- allow( HTTParty ).to receive(:post)
28
-
29
34
  expect{
30
35
  described_class.new('team','token').ping "the message"
31
36
  }.to raise_error
@@ -34,7 +39,6 @@ describe Slack::Notifier do
34
39
  context "with a default channel set" do
35
40
 
36
41
  before :each do
37
- allow( HTTParty ).to receive(:post)
38
42
  @subject = described_class.new('team','token')
39
43
  @subject.channel = 'default'
40
44
  end
@@ -46,17 +50,17 @@ describe Slack::Notifier do
46
50
  end
47
51
 
48
52
  it "uses default channel" do
49
- expect( HTTParty ).to receive(:post)
50
- .with "https://team.slack.com/services/hooks/incoming-webhook?token=token",
51
- body: 'payload={"text":"the message","channel":"default"}'
53
+ expect( Net::HTTP ).to receive(:post_form)
54
+ .with @endpoint_double,
55
+ payload: '{"text":"the message","channel":"default"}'
52
56
 
53
57
  @subject.ping "the message"
54
58
  end
55
59
 
56
60
  it "allows override channel to be set" do
57
- expect( HTTParty ).to receive(:post)
58
- .with "https://team.slack.com/services/hooks/incoming-webhook?token=token",
59
- body: 'payload={"text":"the message","channel":"new"}'
61
+ expect( Net::HTTP ).to receive(:post_form)
62
+ .with @endpoint_double,
63
+ payload: '{"text":"the message","channel":"new"}'
60
64
 
61
65
  @subject.ping "the message", channel: "new"
62
66
  end
@@ -64,9 +68,9 @@ describe Slack::Notifier do
64
68
  end
65
69
 
66
70
  it "posts with the correct endpoint & data" do
67
- expect( HTTParty ).to receive(:post)
68
- .with "https://team.slack.com/services/hooks/incoming-webhook?token=token",
69
- body: 'payload={"text":"the message","channel":"channel"}'
71
+ expect( Net::HTTP ).to receive(:post_form)
72
+ .with @endpoint_double,
73
+ payload: '{"text":"the message","channel":"channel"}'
70
74
 
71
75
  described_class.new("team","token").ping "the message", channel: "channel"
72
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan
@@ -9,22 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-03-02 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: httparty
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '0.11'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '0.11'
27
- description: ' A slim ruby wrapper for posting to slack channels '
12
+ dependencies: []
13
+ description: ' A slim ruby wrapper for posting to slack webhooks '
28
14
  email:
29
15
  - stevenosloan@gmail.com
30
16
  executables: []
@@ -60,7 +46,7 @@ rubyforge_project:
60
46
  rubygems_version: 2.2.2
61
47
  signing_key:
62
48
  specification_version: 4
63
- summary: A slim ruby wrapper for posting to slack channels
49
+ summary: A slim ruby wrapper for posting to slack webhooks
64
50
  test_files:
65
51
  - spec/lib/slack-notifier/link_formatter_spec.rb
66
52
  - spec/lib/slack-notifier_spec.rb