Sha256: 9d870bdca1e340ce9a453e277b6ba4b9f6d5d079495ae3b0f80df6b4ed28a684

Contents?: true

Size: 907 Bytes

Versions: 15

Compression:

Stored size: 907 Bytes

Contents

#! /usr/bin/env ruby

require 'spec_helper'

describe "id fact" do
  include FacterSpec::ConfigHelper

  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
        given_a_configuration_of(:is_windows => k == 'windows')
        Facter.fact(:kernel).stubs(:value).returns(k)
        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
    given_a_configuration_of(:is_windows => 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

15 entries across 15 versions & 1 rubygems

Version Path
facter-1.7.6 spec/unit/id_spec.rb
facter-1.7.5 spec/unit/id_spec.rb
facter-1.7.5.rc2 spec/unit/id_spec.rb
facter-1.7.5.rc1 spec/unit/id_spec.rb
facter-1.7.4 spec/unit/id_spec.rb
facter-1.7.4.rc1 spec/unit/id_spec.rb
facter-1.7.3 spec/unit/id_spec.rb
facter-1.7.3.rc1 spec/unit/id_spec.rb
facter-1.7.2 spec/unit/id_spec.rb
facter-1.7.2.rc1 spec/unit/id_spec.rb
facter-1.7.1 spec/unit/id_spec.rb
facter-1.7.1.rc1 spec/unit/id_spec.rb
facter-1.7.0 spec/unit/id_spec.rb
facter-1.7.0.rc2 spec/unit/id_spec.rb
facter-1.7.0.rc1 spec/unit/id_spec.rb