-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b9c158
commit b096652
Showing
8 changed files
with
128 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Icinga2::API::Host do | ||
|
||
let(:client) { Icinga2::API::Client.new('https://icinga2.example.net:5665', icinga_credentials) } | ||
subject(:host) { client.hosts.find('foo.example.net') } | ||
|
||
subject { client.hosts.find('foo.example.net') } | ||
let(:client) { Icinga2::API::Client.new('https://icinga2.example.net:5665', icinga_credentials) } | ||
|
||
describe '#api_client' do | ||
it 'should return the previous defined client' do | ||
it 'returns the previous defined client' do | ||
VCR.use_cassette('single_host') do | ||
expect(subject.api_client).to eq client | ||
expect(host.api_client).to eq client | ||
end | ||
end | ||
end | ||
|
||
describe '#to_s' do | ||
it 'should return Icinga2 host name' do | ||
it 'returns Icinga2 host name' do | ||
VCR.use_cassette('single_host') do | ||
expect(subject.to_s).to eq 'foo.example.net' | ||
expect(host.to_s).to eq 'foo.example.net' | ||
end | ||
end | ||
end | ||
|
||
describe '#to_h' do | ||
it 'should return host attributes as a hash' do | ||
it 'returns host attributes as a hash' do | ||
VCR.use_cassette('single_host') do | ||
expect(subject.to_h).to be_a(Hash) | ||
expect(subject.to_h[:name]).to eq 'foo.example.net' | ||
expect(host.to_h).to be_a(Hash) | ||
expect(host.to_h[:name]).to eq 'foo.example.net' | ||
end | ||
end | ||
end | ||
|
||
describe '#name' do | ||
it 'should return Icinga2 host name' do | ||
it 'returns Icinga2 host name' do | ||
VCR.use_cassette('single_host') do | ||
expect(subject.to_s).to eq 'foo.example.net' | ||
expect(host.name).to eq 'foo.example.net' | ||
end | ||
end | ||
end | ||
|
||
describe '#services' do | ||
it 'should return Icinga2 host services' do | ||
it 'returns Icinga2 host services' do | ||
VCR.use_cassette('single_host_with_services') do | ||
expect(subject.services).to be_a(Icinga2::API::Services) | ||
expect(subject.services.host).to eq subject | ||
expect(subject.services.api_client).to eq subject.api_client | ||
expect(host.services).to be_a(Icinga2::API::Services) | ||
expect(host.services.host).to eq host | ||
expect(host.services.api_client).to eq host.api_client | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.