2015-12-11 16:03:12 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2016-01-28 13:51:54 +00:00
|
|
|
if os.linux?
|
|
|
|
# uses the `cmp` matcher instead of the eq matcher
|
|
|
|
describe sshd_config do
|
|
|
|
its('Port') { should eq '22' }
|
|
|
|
its('Port') { should_not eq 22 }
|
2015-12-11 16:03:12 +00:00
|
|
|
|
2016-01-28 13:51:54 +00:00
|
|
|
its('Port') { should cmp '22' }
|
|
|
|
its('Port') { should cmp 22 }
|
|
|
|
its('Port') { should cmp 22.0 }
|
|
|
|
its('Port') { should_not cmp 22.1 }
|
2015-12-11 16:03:12 +00:00
|
|
|
|
2016-05-10 17:23:11 +00:00
|
|
|
its('LogLevel') { should eq 'VERBOSE' }
|
|
|
|
its('LogLevel') { should_not eq 'verbose'}
|
2015-12-11 16:03:12 +00:00
|
|
|
|
2016-05-10 17:23:11 +00:00
|
|
|
its('LogLevel') { should cmp 'VERBOSE' }
|
|
|
|
its('LogLevel') { should cmp 'verbose' }
|
|
|
|
its('LogLevel') { should cmp 'VerBose' }
|
2016-01-28 13:51:54 +00:00
|
|
|
end
|
2016-02-18 11:08:57 +00:00
|
|
|
|
|
|
|
describe passwd.passwords.uniq do
|
|
|
|
it { should eq ['x'] }
|
|
|
|
it { should cmp ['x'] }
|
|
|
|
it { should cmp 'x' }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe passwd.usernames do
|
|
|
|
it { should include 'root' }
|
|
|
|
it { should_not cmp 'root' }
|
|
|
|
end
|
2016-02-23 21:31:10 +00:00
|
|
|
|
|
|
|
len = passwd.passwords.length
|
|
|
|
describe len do
|
|
|
|
it { should cmp len.to_s }
|
|
|
|
end
|
2016-04-15 13:11:45 +00:00
|
|
|
|
2016-04-20 09:39:46 +00:00
|
|
|
describe 122 do
|
|
|
|
it { should cmp 122 }
|
|
|
|
it { should cmp < 133 }
|
|
|
|
it { should cmp > 111 }
|
|
|
|
it { should_not cmp < 122 }
|
|
|
|
it { should_not cmp > 122 }
|
|
|
|
it { should cmp <= 122 }
|
|
|
|
it { should cmp >= 122 }
|
|
|
|
it { should cmp >= -666 }
|
|
|
|
it { should_not cmp <= 111 }
|
|
|
|
it { should_not cmp >= 133 }
|
|
|
|
it { should cmp /122/ }
|
|
|
|
it { should_not cmp /133/ }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 0o640 do
|
|
|
|
it { should cmp 0o640 }
|
|
|
|
it { should cmp > 100 }
|
|
|
|
it { should_not cmp <= 0 }
|
|
|
|
it { should cmp == '416' }
|
|
|
|
it { should cmp /416$/ }
|
|
|
|
end
|
|
|
|
|
2016-04-15 13:11:45 +00:00
|
|
|
describe '12' do
|
2016-04-20 09:39:46 +00:00
|
|
|
it { should cmp 12 }
|
2016-04-15 13:11:45 +00:00
|
|
|
it { should cmp < 13 }
|
|
|
|
it { should cmp > 11 }
|
|
|
|
it { should_not cmp < 12 }
|
|
|
|
it { should_not cmp > 12 }
|
|
|
|
it { should cmp <= 12 }
|
|
|
|
it { should cmp >= 12 }
|
2016-04-20 09:39:46 +00:00
|
|
|
it { should cmp >= -666 }
|
2016-04-15 13:11:45 +00:00
|
|
|
it { should_not cmp <= 11 }
|
|
|
|
it { should_not cmp >= 13 }
|
|
|
|
end
|
|
|
|
|
2016-06-15 15:22:25 +00:00
|
|
|
# Don't compare octal to number
|
|
|
|
describe '07' do
|
|
|
|
it { should_not cmp 7 }
|
|
|
|
end
|
|
|
|
|
2016-04-20 09:39:46 +00:00
|
|
|
describe 'some 123' do
|
|
|
|
it { should cmp 'some 123' }
|
|
|
|
it { should cmp /^SOME\s\d+(1|2|3)3/i }
|
|
|
|
it { should_not cmp /^SOME/ }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe ['some-array'] do
|
|
|
|
it { should cmp 'some-array' }
|
|
|
|
it { should cmp /.+/ }
|
|
|
|
it { should_not cmp /^SOME/ }
|
|
|
|
end
|
|
|
|
|
2016-04-15 13:11:45 +00:00
|
|
|
describe '' do
|
|
|
|
it { should_not cmp >= 3 }
|
|
|
|
it { should_not cmp < 3 }
|
2016-04-20 09:39:46 +00:00
|
|
|
it { should_not cmp /.+/ }
|
2016-04-15 13:11:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe nil do
|
2016-04-20 09:39:46 +00:00
|
|
|
it { should cmp nil }
|
2016-04-15 13:11:45 +00:00
|
|
|
it { should_not cmp >= 3 }
|
|
|
|
it { should_not cmp < 3 }
|
2016-04-20 09:39:46 +00:00
|
|
|
it { should_not cmp /something/ }
|
2016-04-15 13:11:45 +00:00
|
|
|
end
|
2016-06-18 18:33:08 +00:00
|
|
|
|
|
|
|
describe true do
|
|
|
|
it { should cmp 'true' }
|
|
|
|
it { should cmp 'True' }
|
|
|
|
it { should cmp true }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe false do
|
|
|
|
it { should cmp 'false' }
|
|
|
|
it { should cmp 'False' }
|
|
|
|
it { should cmp false }
|
|
|
|
end
|
2015-12-11 16:03:12 +00:00
|
|
|
end
|