Sha256: c018720e5cef0b75206636dc6924eba08b954756c2a113c642b3fbe187e9cc81
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
#! /usr/bin/env ruby require 'spec_helper' describe "Hostname facts" do describe "on linux" do before do Facter.fact(:kernel).stubs(:value).returns("Linux") Facter.fact(:kernelrelease).stubs(:value).returns("2.6") end it "should use the hostname command" do Facter::Core::Execution.expects(:exec).with('hostname').at_least_once Facter.fact(:hostname).value.should be_nil end it "should use hostname as the fact if unqualified" do Facter::Core::Execution.stubs(:exec).with('hostname').returns('host1') Facter.fact(:hostname).value.should == "host1" end it "should truncate the domain name if qualified" do Facter::Core::Execution.stubs(:exec).with('hostname').returns('host1.example.com') Facter.fact(:hostname).value.should == "host1" end end describe "on darwin release R7" do before do Facter.fact(:kernel).stubs(:value).returns("Darwin") Facter.fact(:kernelrelease).stubs(:value).returns("R7") end it "should use scutil to get the hostname" do Facter::Core::Execution.expects(:exec).with('/usr/sbin/scutil --get LocalHostName', anything).returns("host1") Facter.fact(:hostname).value.should == "host1" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facter-2.0.1.rc2 | spec/unit/hostname_spec.rb |
facter-2.0.1.rc2-x86-mingw32 | spec/unit/hostname_spec.rb |
facter-2.0.1.rc2-universal-darwin | spec/unit/hostname_spec.rb |