Sha256: dd945032b2c5251aa1db636d238d545e77b10f76543ef7191087acec02d806cf

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')

describe Ohai::System, "plugin etc" do
  before(:each) do
    @ohai = Ohai::System.new
    @ohai.stub!(:require_plugin).and_return(true)
  end

  PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos)
  GroupEntry = Struct.new(:name, :gid, :mem)

  it "should include a list of all users" do
    Etc.should_receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')).
      and_yield(PasswdEntry.new('www', 800, 800, '/var/www', '/bin/false', 'Serving the web since 1970'))
    @ohai._require_plugin("passwd")
    @ohai[:etc][:passwd]['root'].should == Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')
    @ohai[:etc][:passwd]['www'].should == Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www')
  end
  
  it "should set the current user" do
    Etc.should_receive(:getlogin).and_return('chef')
    @ohai._require_plugin("passwd")
    @ohai[:current_user].should == 'chef'
  end
  
  it "should set the available groups" do
    Etc.should_receive(:group).and_yield(GroupEntry.new("admin", 100, ['root', 'chef'])).and_yield(GroupEntry.new('www', 800, ['www', 'deploy']))
    @ohai._require_plugin("passwd")
    @ohai[:etc][:group]['admin'].should == Mash.new(:gid => 100, :members => ['root', 'chef'])
    @ohai[:etc][:group]['www'].should == Mash.new(:gid => 800, :members => ['www', 'deploy'])
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ohai-0.6.4 spec/ohai/plugins/passwd_spec.rb
ohai-0.6.2 spec/ohai/plugins/passwd_spec.rb
ohai-0.6.2.rc.0 spec/ohai/plugins/passwd_spec.rb
ohai-0.6.0 spec/ohai/plugins/passwd_spec.rb
ohai-0.6.0.beta.0 spec/ohai/plugins/passwd_spec.rb
ohai-0.5.8 spec/ohai/plugins/passwd_spec.rb
ohai-0.5.8.rc.0 spec/ohai/plugins/passwd_spec.rb
ohai-0.5.6 spec/ohai/plugins/passwd_spec.rb
ohai-0.5.4 spec/ohai/plugins/passwd_spec.rb
ohai-0.5.2 spec/ohai/plugins/passwd_spec.rb