Sha256: 7c32473b57d2fe1cdfebf66dedd03c3f8190e3c719cd14ebf0a6974eafd3a427

Contents?: true

Size: 1.24 KB

Versions: 72

Compression:

Stored size: 1.24 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(:execute).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(:execute).with('hostname').returns('host1')
      Facter.fact(:hostname).value.should == "host1"
    end

    it "should truncate the domain name if qualified" do
      Facter::Core::Execution.stubs(:execute).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(:execute).with('/usr/sbin/scutil --get LocalHostName', anything).returns("host1")
      Facter.fact(:hostname).value.should == "host1"
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
facter-2.5.7 spec/unit/hostname_spec.rb
facter-2.5.7-x86-mingw32 spec/unit/hostname_spec.rb
facter-2.5.7-x64-mingw32 spec/unit/hostname_spec.rb
facter-2.5.7-universal-darwin spec/unit/hostname_spec.rb
facter-2.5.6-x86-mingw32 spec/unit/hostname_spec.rb
facter-2.5.6-x64-mingw32 spec/unit/hostname_spec.rb
facter-2.5.6-universal-darwin spec/unit/hostname_spec.rb
facter-2.5.6 spec/unit/hostname_spec.rb
facter-2.5.5-x86-mingw32 spec/unit/hostname_spec.rb
facter-2.5.5-x64-mingw32 spec/unit/hostname_spec.rb
facter-2.5.5-universal-darwin spec/unit/hostname_spec.rb
facter-2.5.5 spec/unit/hostname_spec.rb
facter-2.5.4-x86-mingw32 spec/unit/hostname_spec.rb
facter-2.5.4-x64-mingw32 spec/unit/hostname_spec.rb
facter-2.5.4-universal-darwin spec/unit/hostname_spec.rb
facter-2.5.4 spec/unit/hostname_spec.rb
facter-2.5.1 spec/unit/hostname_spec.rb
facter-2.5.1-x86-mingw32 spec/unit/hostname_spec.rb
facter-2.5.1-x64-mingw32 spec/unit/hostname_spec.rb
facter-2.5.1-universal-darwin spec/unit/hostname_spec.rb