Chef development model for new cooks


#1

Hello Chef,

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?

Any comments are greatly welcome!

Thanks,
Robert


#2

I don’t think you’d use one over the other.

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 ).

sh

?


From: Robert Freiberger rfreiberger@gmail.com
Sent: Tuesday, March 03, 2015 1:09 PM
To: chef@lists.opscode.com
Subject: [chef] Chef development model for new cooks

Hello Chef,

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?

Any comments are greatly welcome!

Thanks,
Robert


#3

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

for reference, i’ve got a fairly well-tested public cookbook that shows how
they kind of fit together over at
https://github.com/nathwill/chef-haproxy-ng (check out the test and spec
directories, and the Rakefile).

HTH,

  • Nathan

On Tue, Mar 3, 2015 at 1:20 PM, Hajducko, Steven <Steven_Hajducko@intuit.com

wrote:

I don’t think you’d use one over the other.

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 ).

sh

From: Robert Freiberger rfreiberger@gmail.com
Sent: Tuesday, March 03, 2015 1:09 PM
To: chef@lists.opscode.com
Subject: [chef] Chef development model for new cooks

Hello Chef,

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?

Any comments are greatly welcome!

Thanks,
Robert