Class: RSpec::Core::ExampleGroup
- Inherits:
-
Object
- Object
- RSpec::Core::ExampleGroup
- Defined in:
- lib/simple_approvals/chefspec/approvals.rb
Overview
open up ExampleGroup to add template approval helpers
Class Method Summary collapse
- .verify_chef_file(**file) ⇒ Object
- .verify_chef_files(*specs) ⇒ Object
-
.verify_chef_template(**file) ⇒ Object
verify one template:.
-
.verify_chef_templates(*specs) ⇒ Object
verify a set of templates:.
Class Method Details
.verify_chef_file(**file) ⇒ Object
44 45 46 47 |
# File 'lib/simple_approvals/chefspec/approvals.rb', line 44 def verify_chef_file(**file) file[:scrubber] = ->(rendered_content) { yield rendered_content } if block_given? include_examples 'an approved chef template', file end |
.verify_chef_files(*specs) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/simple_approvals/chefspec/approvals.rb', line 75 def verify_chef_files(*specs) specs.each do |file| file[:scrubber] = ->(rendered_content) { yield rendered_content } if block_given? verify_chef_file(file) end end |
.verify_chef_template(**file) ⇒ Object
verify one template:
verify_chef_template(expected_path: '', approved path: '')
38 39 40 41 42 |
# File 'lib/simple_approvals/chefspec/approvals.rb', line 38 def verify_chef_template(**file) file[:template] = true file[:scrubber] = ->(rendered_content) { yield rendered_content } if block_given? verify_chef_file(**file) end |
.verify_chef_templates(*specs) ⇒ Object
verify a set of templates:
verify_chef_templates(
{ expected_path: '',
approved path: ''
},
{ expected_path: ''
approved path: ''
}
)
note: this requires that rubocop is configued like this:
BracesAroundHashParameters:
EnforcedStyle: context_dependent
which is taken care of in the shared lib/.chef-rubocop.yml
67 68 69 70 71 72 73 |
# File 'lib/simple_approvals/chefspec/approvals.rb', line 67 def verify_chef_templates(*specs) specs.each do |file| file[:scrubber] = ->(rendered_content) { yield rendered_content } if block_given? file[:template] = true verify_chef_file(file) end end |