Sha256: eda00a421ff95f261b1feeb99cbc31d498565af65e1c48afffcb11ddf0b505b7

Contents?: true

Size: 1.31 KB

Versions: 29

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'facter/root_home'

describe Facter::Util::RootHome do
  context "solaris" do
    let(:root_ent) { "root:x:0:0:Super-User:/:/sbin/sh" }
    let(:expected_root_home) { "/" }

    it "should return /" do
      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
      Facter::Util::RootHome.get_root_home.should == expected_root_home
    end
  end
  context "linux" do
    let(:root_ent) { "root:x:0:0:root:/root:/bin/bash" }
    let(:expected_root_home) { "/root" }

    it "should return /root" do
      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
      Facter::Util::RootHome.get_root_home.should == expected_root_home
    end
  end
  context "macosx" do
    let(:root_ent) { "root:*:0:0:System Administrator:/var/root:/bin/sh" }
    let(:expected_root_home) { "/var/root" }

    it "should return /var/root" do
      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(root_ent)
      Facter::Util::RootHome.get_root_home.should == expected_root_home
    end
  end
  context "windows" do
    before :each do
      Facter::Util::Resolution.expects(:exec).with("getent passwd root").returns(nil)
    end
    it "should be nil on windows" do
      Facter::Util::RootHome.get_root_home.should be_nil
    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
freighthop-0.6.1 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.6.0 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.5.2 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.5.1 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.5.0 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.4.1 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.4.0 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.3.3 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.3.2 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.3.1 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.3.0 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.2.1 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.2.0 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.1.0 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.0.6 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.0.5 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.0.4 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.0.3 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.0.2 modules/stdlib/spec/unit/facter/root_home_spec.rb
freighthop-0.0.1 modules/stdlib/spec/unit/facter/root_home_spec.rb