Class: Inspec::Resources::Group
- Inherits:
-
Object
- Object
- Inspec::Resources::Group
- Includes:
- GroupManagementSelector
- Defined in:
- lib/resources/groups.rb
Overview
Usage: describe group(‘root’) do
it { should exist }
its('gid') { should eq 0 }
end
deprecated has matcher describe group(‘root’) do
it { should have_gid 0 }
end
Instance Method Summary collapse
-
#exists? ⇒ Boolean
verifies if a group exists.
- #gid ⇒ Object
-
#has_gid?(compare_gid) ⇒ Boolean
implements rspec has matcher, to be compatible with serverspec.
-
#initialize(groupname) ⇒ Group
constructor
A new instance of Group.
- #local ⇒ Object
- #to_s ⇒ Object
Methods included from GroupManagementSelector
Constructor Details
#initialize(groupname) ⇒ Group
Returns a new instance of Group.
91 92 93 94 95 96 97 98 |
# File 'lib/resources/groups.rb', line 91 def initialize(groupname) @group = groupname @group = @group.downcase unless inspec.os.windows? # select group manager @group_provider = select_group_manager(inspec.os) return skip_resource 'The `group` resource is not supported on your OS yet.' if @group_provider.nil? end |
Instance Method Details
#exists? ⇒ Boolean
verifies if a group exists
101 102 103 |
# File 'lib/resources/groups.rb', line 101 def exists? !group_info.entries.empty? end |
#gid ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/resources/groups.rb', line 105 def gid gids = group_info.gids if gids.empty? nil # the default case should be one group elsif gids.size == 1 gids.entries[0] else raise 'found more than one group with the same name, please use `groups` resource' end end |
#has_gid?(compare_gid) ⇒ Boolean
implements rspec has matcher, to be compatible with serverspec
118 119 120 |
# File 'lib/resources/groups.rb', line 118 def has_gid?(compare_gid) gid == compare_gid end |
#local ⇒ Object
122 123 124 125 |
# File 'lib/resources/groups.rb', line 122 def local # at this point the implementation only returns local groups true end |
#to_s ⇒ Object
127 128 129 |
# File 'lib/resources/groups.rb', line 127 def to_s "Group #{@group}" end |