Skip to content

Instantly share code, notes, and snippets.

@jeansymolanza
Last active December 17, 2024 12:32
Show Gist options
  • Save jeansymolanza/be05958016eba3de8b418df86bb26ec4 to your computer and use it in GitHub Desktop.
Save jeansymolanza/be05958016eba3de8b418df86bb26ec4 to your computer and use it in GitHub Desktop.
context 'when se_linux mount exists' do
before do
# Mock File.directory? with any_args as you have
allow(File).to receive(:directory?).with(any_args).and_return(true)
# Mock shell_out for the ls -Z command exactly as you have
allow_any_instance_of(Chef::Resource).to receive(:shell_out)
.with('ls -Z /mnt/tmpfs | grep tmp_t')
.and_return(double('shell_out', exitstatus: 1))
# Add this line to fix your current error - this matches your File.read setup
allow(File).to receive(:read)
.with('/proc/mounts')
.and_return('/mnt/tmpfs tmpfs tmpfs rw,size=70 0 0\n')
end
it 'runs the config_mount_selinux block' do
expect(chef_run).to run_execute('config_mount_selinux')
.with(command: 'chcon -t tmp_t /mnt/tmpfs')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment