-2

How do I check the cron entry 0 5 * * * /usr/bin/aide --check with a regex? I would like to check this in Chef InSpec like

its('content') { should match /<the regular expression>/ }
StephenKing
  • 36,187
  • 11
  • 83
  • 112
user3121011
  • 449
  • 3
  • 12
  • Possible duplicate of [Learning Regular Expressions](http://stackoverflow.com/questions/4736/learning-regular-expressions) – hek2mgl Nov 14 '16 at 18:11

2 Answers2

2
describe cron do
  it { expect(subject).to have_entry '0 5 * * * /usr/bin/aide --check' }
end

is the proper way to do this in Serverspec and will also solve your problem with formatting immediately.

If you really wanted to use a regexp (and your followup comment left as an answer implies you don't), then you could do:

its(:content) { is_expected.to match %r{0 5 \* \* \* /usr/bin/aide --check} }
Matthew Schuchard
  • 25,172
  • 3
  • 47
  • 67
0

The regex could be /0 5 * * * \/usr\/bin\/aide --check/

user3121011
  • 449
  • 3
  • 12