Sha256: a26ce370db4cb8a0d63cf24cdb4773fefd0a2a7288a52acdaacd6e136370578a

Contents?: true

Size: 1.54 KB

Versions: 32

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe "gid fact" do

  describe "on non-SunOS systems with id" do
    it "should return the current group" do
      Facter.fact(:kernel).stubs(:value).returns("Linux")
      Facter::Core::Execution.expects(:which).with('id').returns(true)
      Facter::Core::Execution.expects(:exec).once.with('id -ng').returns 'bar'

      Facter.fact(:gid).value.should == 'bar'
    end
  end

  describe "on non-SunOS systems without id" do
    it "is not supported" do
      Facter.fact(:kernel).stubs(:value).returns("Linux")
      Facter::Core::Execution.expects(:which).with('id').returns(false)

      Facter.fact(:gid).value.should == nil
    end
  end

  describe "on SunOS systems with /usr/xpg4/bin/id" do
    it "should return the current group" do
      Facter.fact(:kernel).stubs(:value).returns("SunOS")
      File.expects(:exist?).with('/usr/xpg4/bin/id').returns true
      Facter::Core::Execution.expects(:exec).with('/usr/xpg4/bin/id -ng').returns 'bar'

      Facter.fact(:gid).value.should == 'bar'
    end
  end

  describe "on SunOS systems without /usr/xpg4/bin/id" do
    it "is not supported" do
      Facter.fact(:kernel).stubs(:value).returns("SunOS")
      File.expects(:exist?).with('/usr/xpg4/bin/id').returns false

      Facter.fact(:gid).value.should == nil
    end
  end

  describe "on windows systems" do
    it "is not supported" do
      Facter.fact(:kernel).stubs(:value).returns("windows")
      Facter::Core::Execution.expects(:which).with('id').returns(true)

      Facter.fact(:gid).value.should == nil
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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