Send status through Notifier class.
This commit is contained in:
parent
726923c18f
commit
125025e078
17
lib/nsca/client/notifier.rb
Normal file
17
lib/nsca/client/notifier.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'send_nsca'
|
||||
|
||||
module NSCA
|
||||
module Client
|
||||
class Notifier
|
||||
def initialize(message)
|
||||
@message = message
|
||||
end
|
||||
|
||||
def send_nsca
|
||||
connection = SendNsca::NscaConnection.new(@message.to_h)
|
||||
connection.send_nsca
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
20
spec/nsca/client/notifier_spec.rb
Normal file
20
spec/nsca/client/notifier_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe NSCA::Client::Notifier do
|
||||
let(:server) { NSCA::Client::RemoteServer.new(:host => '172.0.0.1') }
|
||||
let(:host) { NSCA::Client::Host.new(:hostname => 'dummy') }
|
||||
let(:service) { NSCA::Client::Service.new(:name => 'TestMessage', :host => host) }
|
||||
let(:message) { NSCA::Client::Message.new(:ok, 'OK', service, server) }
|
||||
|
||||
context "send message successfully" do
|
||||
before do
|
||||
SendNsca::NscaConnection.any_instance.should_receive(:send_nsca)
|
||||
end
|
||||
|
||||
let(:notifier) { NSCA::Client::Notifier.new(message) }
|
||||
|
||||
subject { notifier.send_nsca }
|
||||
|
||||
it { should be_true }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue