I’m very new to Ruby and Chef, where I have created basic cookbooks and
recipes using various resources. At work, I’m starting to add my cookbooks
into production but they need to pass various testing.
From many Chef guides and books, I’m not understanding the full path of
proper Chef development. I have started to learn about using berks, and
bundle, but how should I use foodcritic over the other tools like ChefSpec
and ServerSpec?
As a relatively new Chef myself, I’ve found that there is a place for all three. FoodCritic is a linter. It catches common mistakes and makes you conform to the ChefStyle guide.
ChefSpec is for testing that your cookbook is saying that it’s doing something. ( https://sethvargo.com/unit-testing-chef-cookbooks/ ). IE - My cookbook says to install the package httpd on a RedHat system. You should spend some time on Seth’s blog - lots of good information there.
ServerSpec is, for me, the final test. It actually runs and tests the system to make sure that what I told my cookbook to do, actually works right on a system.
I run all these through TestKitchen and Guard ( This post is a little outdated but helped me out quite a bit: https://micgo.net/ ).
I’m sure other Chefs will have more substantial information ( or correct mine ).
I’m very new to Ruby and Chef, where I have created basic cookbooks and recipes using various resources. At work, I’m starting to add my cookbooks into production but they need to pass various testing.
From many Chef guides and books, I’m not understanding the full path of proper Chef development. I have started to learn about using berks, and bundle, but how should I use foodcritic over the other tools like ChefSpec and ServerSpec?
we use a full mix of testing frameworks as well, each covering what they're
good for. rubocop for ruby style, foodcritic for cookbook linting, chefspec
for unit testing, and serverspec for integration testing. I second the
recommendation to check out Seth's blog, lots of good stuff there
As a relatively new Chef myself, I've found that there is a place for
all three. FoodCritic is a linter. It catches common mistakes and makes
you conform to the ChefStyle guide.
ChefSpec is for testing that your cookbook is saying that it's doing
something. ( Unit Testing Chef Cookbooks | Seth Vargo ). IE -
My cookbook says to install the package httpd on a RedHat system. You
should spend some time on Seth's blog - lots of good information there.
ServerSpec is, for me, the final test. It actually runs and tests the
system to make sure that what I told my cookbook to do, actually works
right on a system.
I run all these through TestKitchen and Guard ( This post is a little
outdated but helped me out quite a bit: https://micgo.net/ ).
I'm sure other Chefs will have more substantial information ( or correct
mine ).
I'm very new to Ruby and Chef, where I have created basic cookbooks and
recipes using various resources. At work, I'm starting to add my cookbooks
into production but they need to pass various testing.
From many Chef guides and books, I'm not understanding the full path of
proper Chef development. I have started to learn about using berks, and
bundle, but how should I use foodcritic over the other tools like ChefSpec
and ServerSpec?