Send status through Notifier class.

master
Felipe Oliveira 2012-12-07 16:39:46 -02:00
parent 726923c18f
commit 125025e078
2 changed files with 37 additions and 0 deletions

View 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

View 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