Sha256: ae613dfa386e66ed0897c90d6cd822ef9382283c654f0e1700b5738e98b1ceef

Contents?: true

Size: 894 Bytes

Versions: 11

Compression:

Stored size: 894 Bytes

Contents

#! /usr/bin/env ruby

require 'spec_helper'

describe "id fact" do

  kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ]

  kernel.each do |k|
    describe "with kernel reported as #{k}" do
      it "should return the current user" do
        Facter.fact(:kernel).stubs(:value).returns(k)
        Facter::Util::Config.stubs(:is_windows?).returns(k == 'windows')
        Facter::Util::Resolution.expects(:exec).once.with('whoami').returns 'bar'

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

  it "should return the current user on Solaris" do
     Facter::Util::Config.stubs(:is_windows?).returns(false)
     Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS')
     Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar'

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

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/facter-1.6.17/spec/unit/id_spec.rb
facter-1.6.18 spec/unit/id_spec.rb
facter-1.6.18.rc1 spec/unit/id_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/facter-1.6.17/spec/unit/id_spec.rb
facter-1.6.17 spec/unit/id_spec.rb
facter-1.6.17.rc1 spec/unit/id_spec.rb
facter-1.6.16 spec/unit/id_spec.rb
facter-1.6.15 spec/unit/id_spec.rb
facter-1.6.15.rc1 spec/unit/id_spec.rb
facter-1.6.14 spec/unit/id_spec.rb
facter-1.6.14.rc1 spec/unit/id_spec.rb