i have the below in my Inspec test:
describe file(’/usr/local/nexus/current’) do
_ its(‘type’) { should eq ‘link’ }_
_ it { should be_symlink }_
_ it { should_not be_file }_
end
The dir ‘/usr/local/nexus/current’ have the below on the box:
[vagrant@default-centos-72 nexus] ll total 0 **lrwxrwxrwx. 1 nexus nexus 35 Dec 19 18:17 current -> /usr/local/nexus/releases/2.12.0-01** drwxr-xr-x. 3 root root 22 Dec 19 18:17 releases drwxr-xr-x. 5 nexus nexus 40 Dec 19 18:17 shared [vagrant@default-centos-72 nexus] exit
Notice the ‘l’ for the ‘link’ , as well as the below documentation for the matcher ‘type’
http://inspec.io/docs/reference/resources/file/
type
The type matcher tests if the first letter of the file’s mode string contains one of the following characters:
- or f (the file is a file); use 'file to test for this file type
d (the file is a directory); use 'directory to test for this file type
l (the file is a symbolic link); use 'link to test for this file type
p (the file is a named pipe); use 'pipe to test for this file type
s (the file is a socket); use 'socket to test for this file type
c (the file is a character device); use 'character to test for this file type
b (the file is a block device); use 'block to test for this file type
D (the file is a door); use 'door to test for this file type
But test fails, saying its a directory
File /usr/local/nexus/current
should be symlink
should not be file
should not be directory
** expected File /usr/local/nexus/current.directory?
to return false, got true**
** type should eq “symlink”**
expected: "symlink"
got: :directory
(compared using ==)
Diff:
@@ -1,2 +1,2 @@
-"symlink"
+:directory