From 86f8428c41bf5ac0d11ce3f523314c8977ebe01a Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Date: Fri, 7 Dec 2012 16:40:40 -0200 Subject: [PATCH] Nagios Service class. --- lib/nsca/client/service.rb | 12 ++++++++++++ spec/nsca/client/service_spec.rb | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lib/nsca/client/service.rb create mode 100644 spec/nsca/client/service_spec.rb diff --git a/lib/nsca/client/service.rb b/lib/nsca/client/service.rb new file mode 100644 index 0000000..795a909 --- /dev/null +++ b/lib/nsca/client/service.rb @@ -0,0 +1,12 @@ +module NSCA + module Client + class Service + attr_accessor :name, :host + + def initialize(options) + @name = options[:name] + @host = options[:host] || Host.current + end + end + end +end diff --git a/spec/nsca/client/service_spec.rb b/spec/nsca/client/service_spec.rb new file mode 100644 index 0000000..c4cd912 --- /dev/null +++ b/spec/nsca/client/service_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe NSCA::Client::Service do + let(:host) { NSCA::Client::Host.new(:hostname => 'asdf') } + subject { described_class.new(:name => 'TestMessage', :host => host) } + + its(:name) { should eq 'TestMessage' } + its(:host) { should eq host } + + context "default host to current machine" do + subject { described_class.new(:name => 'SimpleMessage') } + + its(:name) { should eq 'SimpleMessage' } + its(:host) { should be_a NSCA::Client::Host } + end +end