Project

fakeetc

0.0
No commit activity in last 3 years
No release in over 3 years
FakeEtc is a fake Etc module for your tests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.6.0
~> 10.4.2
~> 0.8.7.6
 Project Readme

fakeetc

Gem Version Build Status Code Climate Test Coverage

A fake Ruby Etc module for your tests.

Intended as a drop-in replacement for Etc in unit tests.

Usage

require 'fakeetc'

FakeEtc.add_groups({
  'empty' => { gid: 42, mem: [] },
  'anonymous' => { gid: 43, mem: ['johndoe'] }
})
FakeEtc.add_users({
  'janedoe' => { uid: 10,
                 gid: 20,
                 gecos: 'Jane Doe',
                 dir: '/home/janedoe',
                 shell: '/bin/zsh' },
  'jackdoe' => { uid: 50,
                 gid: 60,
                 gecos: 'Jack Doe',
                 dir: '/home/jackdoe',
                 shell: '/bin/bash' },
})

anonymous = nil
jack = nil

FakeEtc do
  anonymous = Etc.getgrnam('anonymous')
  jack = Etc.getpwuid(50)
end

anonymous
# => #<struct Struct::Group
#      name="anonymous",
#      passwd="x",
#      gid=43,
#      mem=["johndoe"]>

jack
# => #<struct Struct::Passwd
#      name="jackdoe",
#      passwd="x",
#      uid=50,
#      gid=60,
#      gecos="Jack Doe",
#      dir="/home/jackdoe",
#      shell="/bin/bash",
#      change=nil,
#      uclass=nil,
#      expire=nil>

Copyright

Copyright (c) 2015 Sebastian Boehm. See LICENSE for details.