cpi-event-connector 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/cpi_event_connector/event.rb +2 -3
- data/lib/cpi_event_connector/version.rb +1 -1
- data/spec/event_spec.rb +8 -8
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -10,10 +10,9 @@ module Cpi
|
|
10
10
|
end
|
11
11
|
|
12
12
|
@enabled = false
|
13
|
-
@logger = Logger.new("/dev/null")
|
14
13
|
|
15
|
-
def self.configure(params, logger)
|
16
|
-
@logger = logger
|
14
|
+
def self.configure(params, logger=nil)
|
15
|
+
@logger = logger || Logger.new("/dev/null")
|
17
16
|
@logger.info "CPI Event Connector initialized"
|
18
17
|
@enabled = !!params.delete(:enabled)
|
19
18
|
@logger.info "CPI Event Connector is " + (@enabled ? "" : "not ") + "enabled"
|
data/spec/event_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Cpi::Event do
|
|
19
19
|
let(:connector) { double(Cpi::Connector) }
|
20
20
|
|
21
21
|
it "accepts a hash of connection information" do
|
22
|
-
Cpi::Event.configure(config
|
22
|
+
Cpi::Event.configure(config)
|
23
23
|
|
24
24
|
Cpi::Event.connection_params.should == { :key => "value" }
|
25
25
|
end
|
@@ -36,7 +36,7 @@ describe Cpi::Event do
|
|
36
36
|
let(:content) { "<test />" }
|
37
37
|
|
38
38
|
it "generates and sends an event" do
|
39
|
-
Cpi::Event.configure(real_config
|
39
|
+
Cpi::Event.configure(real_config)
|
40
40
|
|
41
41
|
Cpi::Event.transmit("shipment_shipped", "stuff", content)
|
42
42
|
|
@@ -51,7 +51,7 @@ describe Cpi::Event do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "creates a connection for each thread" do
|
54
|
-
Cpi::Event.configure(config
|
54
|
+
Cpi::Event.configure(config)
|
55
55
|
|
56
56
|
connector1 = double("connector 1")
|
57
57
|
connector2 = double("connector 2")
|
@@ -72,7 +72,7 @@ describe Cpi::Event do
|
|
72
72
|
it "does not transmit when it is not enabled" do
|
73
73
|
real_config[:enabled] = false
|
74
74
|
|
75
|
-
Cpi::Event.configure(real_config
|
75
|
+
Cpi::Event.configure(real_config)
|
76
76
|
Cpi::Generator.should_not_receive(:create_event)
|
77
77
|
# And there shouldn't be an exception
|
78
78
|
|
@@ -86,7 +86,7 @@ describe Cpi::Event do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it "raises exception when no tenant_uid is passed in" do
|
89
|
-
Cpi::Event.configure(real_config
|
89
|
+
Cpi::Event.configure(real_config)
|
90
90
|
Cpi::Generator.should_not_receive(:create_event)
|
91
91
|
expect {Cpi::Event.transmit("message", nil, "content")}.to raise_error(ArgumentError)
|
92
92
|
end
|
@@ -94,18 +94,18 @@ describe Cpi::Event do
|
|
94
94
|
|
95
95
|
describe ".connectivity_test" do
|
96
96
|
it "tells you when the connector is not enabled" do
|
97
|
-
Cpi::Event.configure({enabled: false}
|
97
|
+
Cpi::Event.configure({enabled: false})
|
98
98
|
Cpi::Event.connectivity_test.should == 'Event Connector is not enabled.'
|
99
99
|
end
|
100
100
|
|
101
101
|
it "tells you when the connection params are correct" do
|
102
|
-
Cpi::Event.configure(real_config
|
102
|
+
Cpi::Event.configure(real_config)
|
103
103
|
Cpi::Event.connectivity_test.should == 'Event Connector can connect to AMQP server at localhost:5672'
|
104
104
|
end
|
105
105
|
|
106
106
|
it "returns false when the connection params are incorrect" do
|
107
107
|
real_config[:host] = "doesntwork"
|
108
|
-
Cpi::Event.configure(real_config
|
108
|
+
Cpi::Event.configure(real_config)
|
109
109
|
Cpi::Event.connectivity_test.should == "getaddrinfo: Name or service not known"
|
110
110
|
end
|
111
111
|
end
|