Given the minimal example
# resources/novowel.rb
resource_name :novowel
property :name, String, name_property: true, regex: /\A[^aeiou]\z/
I would like to write the unit tests in spec/unit/resources/novowel_spec.rb
- Resource 'novowel' for name should accept 'k'
- Resource 'novowel' for name should accept '&'
- Resource 'novowel' for name should NOT accept 'a'
- Resource 'novowel' for name should NOT accept 'mm'
to ensure that the name property still works correctly even if the regex is changed for some reason.
I browsed several top notch Chef cookbooks but could not find references for such testing.
How can it be done? Feel free to provide more complex examples with explicitly subclassing Chef::Resource
if that helps achieve the task.
Update 1: Could it be that Chef does NOT FAIL when a property does not fit the regex
? Clearly this should not work:
link '/none' do
owner 'r<oo=t'
to '/usr'
end
but chef-apply
(12.13.37) does not complain about r<oo=t
not matching owner_valid_regex
. It simply converges as if owner
would not have been provided.