sensu-transport 0.0.6 → 0.0.7

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: 2496679cd2381c318009355b8053bc5a6538b38c
4
- data.tar.gz: 0ef31ba66257db7ca775231bcd57fcd08558cdb5
3
+ metadata.gz: 243e8eb1bf19bad3b76515bcebad17dcaf132534
4
+ data.tar.gz: a193c06b33d7b5d33b3e72cc4aafc1a1f7117ee5
5
5
  SHA512:
6
- metadata.gz: eb087f8e880e4e756d592d801fa781b32f38f3c19fe0aaaec87933e95c97ba84d4a8e649991f72ea6d1ae4623ddb96807830b6b8e6c6107371bab01d32a4a9f6
7
- data.tar.gz: 87a36f325889d9bdb440d301d03dcbd56d8249ecc62e9d9e91beb740ec1793204f378945c05451f7ab0029b0b3a4aee0da2823a1c5ef7f4c9d49e617494d76b2
6
+ metadata.gz: a1096bd23af4e5ad5166ca99477b02da0144e7370b3f72131e56bbfb8ff990d140e2bf5fa44a55752e48ae5c5d2dafc359fc24c89f58b69fe40bf7e6ef486dcf
7
+ data.tar.gz: 4597ad573b8c4edd1193d2d43520976e89cc55d3b147a4ea09b5457b568e0879615aaf6e7468d674b3639f0ef4dd5444e5866190e71d69d84f1ff0f52a3f4b38
@@ -49,7 +49,8 @@ module Sensu
49
49
  end
50
50
 
51
51
  def close
52
- @connection.close
52
+ callback = Proc.new { @connection.close }
53
+ connected? ? callback.call : EM.next_tick(callback)
53
54
  end
54
55
 
55
56
  def publish(exchange_type, exchange_name, message, options={}, &callback)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-transport"
5
- spec.version = "0.0.6"
5
+ spec.version = "0.0.7"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu transport abstraction library"
data/spec/base_spec.rb CHANGED
@@ -9,31 +9,31 @@ describe "Sensu::Transport::Base" do
9
9
  end
10
10
 
11
11
  it "provides a transport API (noop)" do
12
- @transport.should respond_to(:on_error, :before_reconnect, :after_reconnect,
13
- :connect, :reconnect, :connected?, :close,
14
- :publish, :subscribe, :unsubscribe,
15
- :acknowledge, :ack, :stats)
12
+ expect(@transport).to respond_to(:on_error, :before_reconnect, :after_reconnect,
13
+ :connect, :reconnect, :connected?, :close,
14
+ :publish, :subscribe, :unsubscribe,
15
+ :acknowledge, :ack, :stats)
16
16
  end
17
17
 
18
18
  it "behaves as expected" do
19
19
  callback = Proc.new { true }
20
- @transport.on_error(&callback).should be_an_instance_of(Proc)
21
- @transport.before_reconnect(&callback).should be_an_instance_of(Proc)
22
- @transport.after_reconnect(&callback).should be_an_instance_of(Proc)
23
- @transport.connect.should eq(nil)
24
- @transport.connect({}).should eq(nil)
25
- @transport.reconnect.should eq(nil)
26
- @transport.connected?.should eq(false)
27
- @transport.close.should eq(nil)
28
- @transport.publish("foo", "bar", "baz").should eq(nil)
29
- @transport.publish("foo", "bar", "baz", {}, &callback).should eq(true)
30
- @transport.subscribe("foo", "bar", nil, {}, &callback).should eq(true)
31
- @transport.unsubscribe.should eq(nil)
32
- @transport.unsubscribe(&callback).should eq(true)
33
- @transport.acknowledge({}).should eq(nil)
34
- @transport.ack({}).should eq(nil)
35
- @transport.acknowledge({}, &callback).should eq(true)
36
- @transport.ack({}, &callback).should eq(true)
37
- @transport.stats("foo", &callback).should eq(true)
20
+ expect(@transport.on_error(&callback)).to be_kind_of(Proc)
21
+ expect(@transport.before_reconnect(&callback)).to be_an_instance_of(Proc)
22
+ expect(@transport.after_reconnect(&callback)).to be_an_instance_of(Proc)
23
+ expect(@transport.connect).to eq(nil)
24
+ expect(@transport.connect({})).to eq(nil)
25
+ expect(@transport.reconnect).to eq(nil)
26
+ expect(@transport.connected?).to eq(false)
27
+ expect(@transport.close).to eq(nil)
28
+ expect(@transport.publish("foo", "bar", "baz")).to eq(nil)
29
+ expect(@transport.publish("foo", "bar", "baz", {}, &callback)).to eq(true)
30
+ expect(@transport.subscribe("foo", "bar", nil, {}, &callback)).to eq(true)
31
+ expect(@transport.unsubscribe).to eq(nil)
32
+ expect(@transport.unsubscribe(&callback)).to eq(true)
33
+ expect(@transport.acknowledge({})).to eq(nil)
34
+ expect(@transport.ack({})).to eq(nil)
35
+ expect(@transport.acknowledge({}, &callback)).to eq(true)
36
+ expect(@transport.ack({}, &callback)).to eq(true)
37
+ expect(@transport.stats("foo", &callback)).to eq(true)
38
38
  end
39
39
  end
@@ -12,17 +12,17 @@ describe "Sensu::Transport::RabbitMQ" do
12
12
  end
13
13
 
14
14
  it "provides a transport API" do
15
- @transport.should respond_to(:on_error, :before_reconnect, :after_reconnect,
16
- :connect, :reconnect, :connected?, :close,
17
- :publish, :subscribe, :unsubscribe,
18
- :acknowledge, :ack, :stats)
15
+ expect(@transport).to respond_to(:on_error, :before_reconnect, :after_reconnect,
16
+ :connect, :reconnect, :connected?, :close,
17
+ :publish, :subscribe, :unsubscribe,
18
+ :acknowledge, :ack, :stats)
19
19
  end
20
20
 
21
21
  it "can publish and subscribe" do
22
22
  async_wrapper do
23
23
  @transport.connect
24
24
  callback = Proc.new do |message|
25
- message.should eq("msg")
25
+ expect(message).to eq("msg")
26
26
  timer(0.5) do
27
27
  async_done
28
28
  end
@@ -31,8 +31,8 @@ describe "Sensu::Transport::RabbitMQ" do
31
31
  @transport.subscribe("direct", "bar", "baz", {}, &callback)
32
32
  timer(1) do
33
33
  @transport.publish("direct", "foo", "msg") do |info|
34
- info.should be_kind_of(Hash)
35
- info.should be_empty
34
+ expect(info).to be_kind_of(Hash)
35
+ expect(info).to be_empty
36
36
  end
37
37
  end
38
38
  end
@@ -47,7 +47,22 @@ describe "Sensu::Transport::RabbitMQ" do
47
47
  timer(1) do
48
48
  @transport.unsubscribe do
49
49
  @transport.close
50
- @transport.connected?.should be_false
50
+ expect(@transport.connected?).to be(false)
51
+ async_done
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ it "can open and close the connection immediately" do
58
+ async_wrapper do
59
+ @transport.connect
60
+ @transport.close
61
+ expect(@transport.connected?).to be(false)
62
+ EM.next_tick do
63
+ expect(@transport.connected?).to be(false)
64
+ timer(1) do
65
+ expect(@transport.connected?).to be(false)
51
66
  async_done
52
67
  end
53
68
  end
@@ -66,8 +81,8 @@ describe "Sensu::Transport::RabbitMQ" do
66
81
  end
67
82
  timer(1) do
68
83
  @transport.publish("direct", "foo", "msg") do |info|
69
- info.should be_kind_of(Hash)
70
- info.should be_empty
84
+ expect(info).to be_kind_of(Hash)
85
+ expect(info).to be_empty
71
86
  end
72
87
  end
73
88
  end
@@ -77,9 +92,9 @@ describe "Sensu::Transport::RabbitMQ" do
77
92
  async_wrapper do
78
93
  @transport.connect
79
94
  @transport.stats("bar") do |info|
80
- info.should be_kind_of(Hash)
81
- info[:messages].should eq(0)
82
- info[:consumers].should eq(0)
95
+ expect(info).to be_kind_of(Hash)
96
+ expect(info[:messages]).to eq(0)
97
+ expect(info[:consumers]).to eq(0)
83
98
  async_done
84
99
  end
85
100
  end
@@ -88,7 +103,7 @@ describe "Sensu::Transport::RabbitMQ" do
88
103
  it "can fail to connect" do
89
104
  async_wrapper do
90
105
  @transport.connect(:port => 5555)
91
- @transport.connected?.should be_false
106
+ expect(@transport.connected?).to be(false)
92
107
  async_done
93
108
  end
94
109
  end
@@ -97,14 +112,14 @@ describe "Sensu::Transport::RabbitMQ" do
97
112
  ssl_dir = File.join(File.dirname(__FILE__), "assets", "ssl", "client")
98
113
  async_wrapper do
99
114
  @transport.connect(
100
- :port => 5671,
101
- :ssl => {
102
- :cert_chain_file => File.join(ssl_dir, "cert.pem"),
103
- :private_key_file => File.join(ssl_dir, "key.pem")
104
- }
105
- )
115
+ :port => 5671,
116
+ :ssl => {
117
+ :cert_chain_file => File.join(ssl_dir, "cert.pem"),
118
+ :private_key_file => File.join(ssl_dir, "key.pem")
119
+ }
120
+ )
106
121
  timer(2) do
107
- @transport.connected?.should be_true
122
+ expect(@transport.connected?).to be(true)
108
123
  async_done
109
124
  end
110
125
  end
@@ -10,7 +10,7 @@ describe "Sensu::Transport" do
10
10
  options = {}
11
11
  transport = Sensu::Transport.connect("rabbitmq", options)
12
12
  timer(1) do
13
- transport.connected?.should be_true
13
+ expect(transport.connected?).to be(true)
14
14
  async_done
15
15
  end
16
16
  end
@@ -21,8 +21,8 @@ describe "Sensu::Transport" do
21
21
  logger = Logger.new(STDOUT)
22
22
  Sensu::Transport.logger = logger
23
23
  transport = Sensu::Transport.connect("rabbitmq")
24
- transport.logger.should eq(logger)
25
- transport.logger.should respond_to(:error)
24
+ expect(transport.logger).to eq(logger)
25
+ expect(transport.logger).to respond_to(:error)
26
26
  async_done
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-em