Sha256: 6dd81caffa7eff2ca936e101e9e688632538a6ae1d62a0d8068e3ef64e4d12ca

Contents?: true

Size: 1.4 KB

Versions: 35

Compression:

Stored size: 1.4 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

require 'puppet/util/user_attr'

describe UserAttr do
  before do
    user_attr = ["foo::::type=role", "bar::::type=normal;profile=foobar"]
    File.stubs(:readlines).returns(user_attr)
  end

  describe "when getting attributes by name" do
    it "should return nil if there is no entry for that name" do
      UserAttr.get_attributes_by_name('baz').should == nil
    end

    it "should return a hash if there is an entry in /etc/user_attr" do
      UserAttr.get_attributes_by_name('foo').class.should == Hash
    end

    it "should return a hash with the name value from /etc/user_attr" do
      UserAttr.get_attributes_by_name('foo')[:name].should == 'foo'
    end

    #this test is contrived
    #there are a bunch of possible parameters that could be in the hash
    #the role/normal is just a the convention of the file
    describe "when the name is a role" do
      it "should contain :type = role" do
        UserAttr.get_attributes_by_name('foo')[:type].should == 'role'
      end
    end

    describe "when the name is not a role" do
      it "should contain :type = normal" do
        UserAttr.get_attributes_by_name('bar')[:type].should == 'normal'
      end
    end

    describe "when the name has more attributes" do
      it "should contain all the attributes" do
        UserAttr.get_attributes_by_name('bar')[:profile].should == 'foobar'
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/unit/util/user_attr_spec.rb
puppet-2.7.25 spec/unit/util/user_attr_spec.rb
puppet-2.7.24 spec/unit/util/user_attr_spec.rb
puppet-2.7.23 spec/unit/util/user_attr_spec.rb
puppet-2.7.22 spec/unit/util/user_attr_spec.rb
puppet-2.7.21 spec/unit/util/user_attr_spec.rb
puppet-2.7.20 spec/unit/util/user_attr_spec.rb
puppet-2.7.20.rc1 spec/unit/util/user_attr_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/util/user_attr_spec.rb
puppet-2.7.19 spec/unit/util/user_attr_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/user_attr_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/util/user_attr_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/user_attr_spec.rb
puppet-2.7.18 spec/unit/util/user_attr_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/user_attr_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/util/user_attr_spec.rb
puppet-2.7.17 spec/unit/util/user_attr_spec.rb
puppet-2.7.16 spec/unit/util/user_attr_spec.rb
puppet-2.7.14 spec/unit/util/user_attr_spec.rb
puppet-2.7.13 spec/unit/util/user_attr_spec.rb