From 7a935a204e1f045265f0308c9939750a3cf5b7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Socho=C5=84?= Date: Fri, 10 Mar 2017 21:13:43 +0100 Subject: [PATCH] Update file.md with example how to test symlinked files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added detailed example why and how. Updated with suggestions from Adam Leff. Signed-off-by: Michał Sochoń --- docs/resources/file.md.erb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/resources/file.md.erb b/docs/resources/file.md.erb index a2f7836ed5..ffcae41f25 100644 --- a/docs/resources/file.md.erb +++ b/docs/resources/file.md.erb @@ -458,3 +458,25 @@ The following example shows how to use the `file` audit resource to verify if th describe command('pgrep ntp') do its('exit_status') { should eq 0 } end + +### Test parameters of symlinked file + +If you need to test the parameters of the target file for a symlink, you can use the `link_path` method for the `file` resource. + +For example, for the following symlink: + + lrwxrwxrwx. 1 root root 11 03-10 17:56 /dev/virtio-ports/com.redhat.rhevm.vdsm -> ../vport2p1 + +... you can write controls for both the link and the target. + + describe file('/dev/virtio-ports/com.redhat.rhevm.vdsm') do + it { should be_symlink } + end + + virito_port_vdsm = file('/dev/virtio-ports/com.redhat.rhevm.vdsm').link_path + describe file(virito_port_vdsm) do + it { should exist } + it { should be_character_device } + it { should be_owned_by 'ovirtagent' } + it { should be_grouped_into 'ovirtagent' } + end