InterviewSolution
Saved Bookmarks
| 1. |
Explain with an example of why ChefSpec is used in Chef. |
|
Answer» ChefSpec is an in-built testing framework for testing resources and recipes. It’s a PART of Chef DEVELOPMENT Kit. Usually, unit tests are written in ChefSpec and is an extension of Behavior Driven Development framework called RSpec for Ruby. A SAMPLE unit test to check if “Nginx” package is installed or not is written as follows: DESCRIBE 'nginx::default' do context 'When all attributes are default, on Ubuntu 16.04' do let(:chef_run) do runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') runner.converge(described_recipe) end it 'install a package' do expect(chef_run).to install_package('nginx') end endwhere
|
|