slack-notifier 2.1.0 → 2.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5599f6fb6901d7b9c7009d6343288916829b97a
|
4
|
+
data.tar.gz: 60d21036bd104a7bda04b8dbb9da0b4a0747a8b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6199f52c950a2470e651937f2f91ceb67abf95d0987b3c7cf441f9fe3e2e8b405a14a3570d110f367c308bdebafe7bd4f797661c9ce6f563d1ec5d54ea077bf
|
7
|
+
data.tar.gz: 9b7efc69cbeaa137a68e6240f94a198e8932ec4ea7deb48b45d9b46b5091b8118a1ad511d455c4eb91de7d38471c5e54119f5122586d7fed6b9463b6b4525daa
|
@@ -2,8 +2,11 @@
|
|
2
2
|
|
3
3
|
require "net/http"
|
4
4
|
|
5
|
+
|
5
6
|
module Slack
|
6
7
|
class Notifier
|
8
|
+
class APIError < StandardError; end
|
9
|
+
|
7
10
|
module Util
|
8
11
|
class HTTPClient
|
9
12
|
class << self
|
@@ -21,7 +24,14 @@ module Slack
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def call
|
24
|
-
http_obj.request
|
27
|
+
http_obj.request(request_obj).tap do |response|
|
28
|
+
unless response.is_a?(Net::HTTPSuccess)
|
29
|
+
raise Slack::Notifier::APIError, <<-MSG
|
30
|
+
The slack API returned an error: #{response.body} (HTTP Code #{response.code})
|
31
|
+
Check the "Handling Errors" section on https://api.slack.com/incoming-webhooks for more information
|
32
|
+
MSG
|
33
|
+
end
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
37
|
private
|
@@ -24,11 +24,31 @@ RSpec.describe Slack::Notifier::Util::HTTPClient do
|
|
24
24
|
|
25
25
|
allow(Net::HTTP).to receive(:new).and_return(net_http_double)
|
26
26
|
allow(net_http_double).to receive(:use_ssl=)
|
27
|
-
allow(net_http_double).to receive(:request)
|
27
|
+
allow(net_http_double).to receive(:request).with(anything) do
|
28
|
+
Net::HTTPOK.new("GET", "200", "OK")
|
29
|
+
end
|
28
30
|
|
29
31
|
expect(net_http_double).to receive(:open_timeout=).with(5)
|
30
32
|
|
31
33
|
http_client.call
|
32
34
|
end
|
33
35
|
end
|
36
|
+
|
37
|
+
describe "#call" do
|
38
|
+
it "raises an error when the response is unsuccessful" do
|
39
|
+
net_http_double = instance_double("Net::HTTP")
|
40
|
+
http_client = described_class.new URI.parse("http://example.com"), {}
|
41
|
+
bad_request = Net::HTTPBadRequest.new("GET", "400", "Bad Request")
|
42
|
+
|
43
|
+
allow(bad_request).to receive(:body).and_return("something_bad")
|
44
|
+
allow(Net::HTTP).to receive(:new).and_return(net_http_double)
|
45
|
+
allow(net_http_double).to receive(:use_ssl=)
|
46
|
+
allow(net_http_double).to receive(:request).with(anything) do
|
47
|
+
bad_request
|
48
|
+
end
|
49
|
+
|
50
|
+
expect { http_client.call }.to raise_error(Slack::Notifier::APIError,
|
51
|
+
/something_bad \(HTTP Code 400\)/)
|
52
|
+
end
|
53
|
+
end
|
34
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " A slim ruby wrapper for posting to slack webhooks "
|
14
14
|
email:
|