Sha256: 340ece44ba5067786d6c7ebb86a097b6ab845d96a3927c39ac5b7fdb12f46e98

Contents?: true

Size: 894 Bytes

Versions: 14

Compression:

Stored size: 894 Bytes

Contents

#!/usr/bin/env rspec

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

14 entries across 14 versions & 2 rubygems

Version Path
facter-1.6.13 spec/unit/id_spec.rb
facter-1.6.13.rc1 spec/unit/id_spec.rb
facter-1.6.12 spec/unit/id_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/facter-1.6.11/spec/unit/id_spec.rb
facter-1.6.12.rc2 spec/unit/id_spec.rb
facter-1.6.12.rc1 spec/unit/id_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/facter-1.6.11/spec/unit/id_spec.rb
facter-1.6.11 spec/unit/id_spec.rb
facter-1.6.10 spec/unit/id_spec.rb
facter-1.6.9 spec/unit/id_spec.rb
facter-1.6.8 spec/unit/id_spec.rb
facter-1.6.7 spec/unit/id_spec.rb
facter-1.6.6 spec/unit/id_spec.rb
facter-1.6.5 spec/unit/id_spec.rb