bearychat-notifier 0.0.4 → 0.0.5

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: 9961e750867ca45a0f9bfb0fe08042220b31116e
4
- data.tar.gz: e93af808d4684997b800ba4793ce5248e18df640
3
+ metadata.gz: 5fa9b8632f7fc862ba434639e8d432ac87acaeaa
4
+ data.tar.gz: 06078fb1302702835b2c5eaf8c1cac425878b13f
5
5
  SHA512:
6
- metadata.gz: e77f0aff03dd2ff3e3f467deebf147ef090a8118892e1aa18db287905662c5ffe693908fab851e598880f9dc0f8696143f07263213e9cced32c335f60e7f8d08
7
- data.tar.gz: e72f2166a9823b5644586edbfab4060c7dd750f8ab1a281658099239b57e673ca013611e55c228cc7a02391f5ab5210cd779e5af1f3a57b409bcaf71d14a476e
6
+ metadata.gz: 637f9195a55dc49e2a50530fb8e91088ba90761ceb64f119ead041de252e44829ab1e79ac316e8539cc9fd7c50e28c2fec921d78bd1fbe32dfaeaaa4d1b41865
7
+ data.tar.gz: d6de2c766283ed34f84b8d612d9e7a885864bc615e8fd37c1670d26c6eb182c823d4e0af0b15a73f4893172b81105d5654fe2e4e6250ec38e64b520f5a9d1c61
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format 'documentation'
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :defaut => :spec
2
7
 
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", '~> 3.3.0'
23
24
  end
@@ -14,7 +14,7 @@ module Bearychat
14
14
  @payload = options
15
15
  end
16
16
 
17
- def ping(text, options)
17
+ def ping(text, options = {})
18
18
  payload.merge!(options)
19
19
  payload.merge!(text: text)
20
20
  params = { payload: payload.to_json }
@@ -30,8 +30,8 @@ module Bearychat
30
30
  socket.use_ssl = true if url.scheme.downcase == "https"
31
31
 
32
32
  http_options.each do |opt, val|
33
- if http.respond_to? "#{opt}="
34
- http.send "#{opt}=", val
33
+ if socket.respond_to? "#{opt}="
34
+ socket.send "#{opt}=", val
35
35
  else
36
36
  warn "Net::HTTP doesn't respond to `#{opt}=`, ignoring that option"
37
37
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module Bearychat
3
3
  class Notifier
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
6
6
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bearychat::Notifier do
4
+ subject { described_class.new 'http://example.com' }
5
+
6
+ describe "#initialize" do
7
+ it "sets the given hook_url to the webhook_url" do
8
+ expect( subject.webhook_url ).to eq 'http://example.com'
9
+ end
10
+
11
+ it "sets the defaut options" do
12
+ subject = described_class.new 'http://example.com', channel: 'all'
13
+ expect( subject.channel ).to eq 'all'
14
+ end
15
+
16
+ it "#channel=" do
17
+ subject = described_class.new 'http://example.com', channel: 'all'
18
+ subject.channel = "general"
19
+ expect( subject.channel ).to eq 'general'
20
+ end
21
+ end
22
+
23
+ describe "#ping" do
24
+ before :each do
25
+ allow( Bearychat::Notifier::HttpClient ).to receive(:post)
26
+ end
27
+
28
+ context "with a defaut channel set" do
29
+ before :each do
30
+ subject.channel = "#defaut"
31
+ end
32
+
33
+ it "does not require a channel to ping" do
34
+ expect{
35
+ subject.ping "the message"
36
+ }.not_to raise_error
37
+ end
38
+
39
+ it "allows override channel to be set" do
40
+ subject.ping "the message", channel: "override"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bearychat::Notifier::HttpClient do
4
+ describe ".post" do
5
+ it "initialize HttpClient with the given uri and params then call" do
6
+ http_post_double = instance_double("Bearychat::Notifier::HttpClient")
7
+ expect( described_class ).to receive(:new)
8
+ .with('uri', 'params')
9
+ .and_return( http_post_double )
10
+
11
+ expect( http_post_double ).to receive( :call )
12
+ described_class.post 'uri', 'params'
13
+ end
14
+ end
15
+
16
+ describe "#initialize" do
17
+ it "setting options HttpClient" do
18
+ http_client = described_class.new('http://example.com/', http_options: { open_timeout: 5 })
19
+
20
+ http_client.call
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'bearychat-notifier'
5
+
6
+ RSpec.configure do |config|
7
+
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bearychat-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - villins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
41
55
  description: A simple wrapper for posting to bearychat channels
42
56
  email:
43
57
  - linshao512@gmail.com
@@ -46,6 +60,7 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
63
+ - ".rspec"
49
64
  - Gemfile
50
65
  - LICENSE.txt
51
66
  - README.md
@@ -55,6 +70,9 @@ files:
55
70
  - lib/bearychat-notifier/http_client.rb
56
71
  - lib/bearychat-notifier/version.rb
57
72
  - lib/exception_notifier/bearychat_notifier.rb
73
+ - spec/lib/beary-notifier_spec.rb
74
+ - spec/lib/bearychat-notifier/http_client_spec.rb
75
+ - spec/spec_helper.rb
58
76
  homepage: ''
59
77
  licenses:
60
78
  - MIT
@@ -79,4 +97,7 @@ rubygems_version: 2.4.8
79
97
  signing_key:
80
98
  specification_version: 4
81
99
  summary: A simple wrapper for posting to bearychat channels
82
- test_files: []
100
+ test_files:
101
+ - spec/lib/beary-notifier_spec.rb
102
+ - spec/lib/bearychat-notifier/http_client_spec.rb
103
+ - spec/spec_helper.rb