-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crontab regex matching #1526
Comments
Hi, @ecbrodie! Thanks for submitting this issue! With resources such as
Would this approach meet your needs? |
@adamleff This code did the trick and allowed me to apply the regex matching on my crontabs like I intended. I would say that it would be nice to support a regex matcher through an |
@ecbrodie I'm glad to hear that you're unblocked. Native RSpec doesn't support using
... requiring you to do something like this:
In addition to the
I think the I will update the documentation with a |
As raised in #1526, adding an additional example showing how a user can use the `where` accessor to find commands matching a pattern and write a test using the results. Signed-off-by: Adam Leff <[email protected]>
As raised in #1526, adding an additional example showing how a user can use the `where` accessor to find commands matching a pattern and write a test using the results. Signed-off-by: Adam Leff <[email protected]>
Description
The crontab resource is unable to apply Regex matching via the
to match
matcher. It would be nice if this were a feature, since I prefer to match a part of the command instead of the whole command in my test. This is especially useful if there are parts of a command that don't care too much about to verify working behaviour, such as paths to a command that are dynamically created by factors including programming language versions.For example, suppose that I am adding a
cron
in my cookbook for running a custom rake task nightly. The rake task could be something likecustom_task
, so I just want my test to ensure that there is a cron command that matches to the regex/rake custom_task/
.Unfortunately, it looks like I can only do an equality check via
include
instead of a regex check withmatch
. So I have to add some hardcoded paths to my test code, which makes me cringe slightly.InSpec and Platform Version
Inspec version 1.15.0
MacOS 10.12.3 (host machine where I am running tests from)
Replication Case
See Description
Possible Solutions
My workaround is to bite my tongue and just use the
include
matcher. I do not think I know the best way to write a PR for this. But I imagine that new code should allow formatch
matcher support inlib/resources/crontab.rb
.The text was updated successfully, but these errors were encountered: