In the Test driven development with InSpec and Unit test with ChefSpec modules, you've learned how to use automated testing to speed up the feedback cycle. Getting feedback early and often can help you release more quickly and with higher quality.
Although your code may behave as you expect, it's also important to ensure your code is easy to read and maintain, and avoids defects that can be difficult to fix later. Lint testing, or linting, is one way to help ensure that your code adheres to standard style guidelines and avoids common problems.
Lint testing is a form of static program analysis, also called static code analysis. A static code analysis tool inspects a program's source code for potential defects without actually running the program.
Lint testing can identify a range of issues, from code that's correct but difficult to read (such as code that uses non-uniform indentation) all the way to code that surely has an error (such as using an invalid character in a variable name).
In this module, you'll use two popular tools that are part of the Chef DK – Cookstyle and Foodcritic – to identify potential issues in variations of the
webserver_test cookbook you created previously.
This module builds on the
webserver_test cookbook that you create in the Test driven development with InSpec and Unit test with ChefSpec modules. We recommend you work through those modules before you begin this one.
If you want to get started right away with this module, or no longer have the code from the previous ones, run this command from the
~/learn-chef directory to create the
chef generate cookbook cookbooks/webserver_testGenerating cookbook webserver_test- Ensuring correct cookbook file content- Committing cookbook files to git- Ensuring delivery configuration- Ensuring correct delivery build cookbook content- Adding delivery configuration to feature branch- Adding build cookbook to feature branch- Merging delivery content feature branch to master Your cookbook is ready. Type `cd cookbooks/webserver_test` to enter it. There are several commands you can run to get started locally developing and testing your cookbook.Type `delivery local --help` to see a full list. Why not start by writing a test? Tests for the default recipe are stored at: test/smoke/default/default_test.rb If you'd prefer to dive right in, the default recipe can be found at: recipes/default.rb
- Test configuration
This module was last tested with this configuration:
- A workstation running Ubuntu 16.04 on VMware Fusion
- Software: Vagrant 2.0.0, VirtualBox 5.1, Chef Development Kit 2.3.4