Host class that represents machine monitored.

This commit is contained in:
Felipe Oliveira 2012-12-07 16:37:23 -02:00
parent 6c7814d754
commit ca40c4a229
2 changed files with 29 additions and 0 deletions

17
lib/nsca/client/host.rb Normal file
View file

@ -0,0 +1,17 @@
require 'socket'
module NSCA
module Client
class Host
attr_reader :hostname
def initialize(options)
@hostname = options[:hostname]
end
def self.current
Host.new(:hostname => Socket.gethostname)
end
end
end
end

View file

@ -0,0 +1,12 @@
require 'spec_helper'
describe NSCA::Client::Host do
subject { described_class.new(:hostname => 'dummy') }
its(:hostname) { should eq 'dummy' }
context "current machine" do
before { Socket.stub(:gethostname).and_return('dummy-client-machine') }
subject { described_class.current }
its(:hostname) { should eq 'dummy-client-machine' }
end
end