Use strainer to isolate and test individual cookbooks
Included: - Add strainer gem - Update test-related gems - Add Strainer file - Remove run_tests.bash - Update .gitignore - Update README file Partial fix for bug 1188345 Change-Id: I440c69a0d6eba46b9cf69559a652264e719714d6
This commit is contained in:
parent
4aa57bc50f
commit
16d36e2acc
|
@ -1,3 +1,2 @@
|
||||||
.bundle
|
.bundle/
|
||||||
.cookbooks/
|
|
||||||
Berksfile.lock
|
Berksfile.lock
|
||||||
|
|
5
Gemfile
5
Gemfile
|
@ -2,6 +2,7 @@ source "https://rubygems.org"
|
||||||
|
|
||||||
gem "chef", "~> 11.4.4"
|
gem "chef", "~> 11.4.4"
|
||||||
gem "json", "<= 1.7.7" # chef 11 dependency
|
gem "json", "<= 1.7.7" # chef 11 dependency
|
||||||
gem "berkshelf", "~> 1.4.0"
|
gem "berkshelf", "~> 1.4.5"
|
||||||
gem "chefspec", "~> 1.2.0"
|
gem "chefspec", "~> 1.2.0"
|
||||||
gem "foodcritic", "~> 2.1.0"
|
gem "foodcritic"
|
||||||
|
gem "strainer"
|
||||||
|
|
11
Gemfile.lock
11
Gemfile.lock
|
@ -103,8 +103,8 @@ GEM
|
||||||
mixlib-config (1.1.2)
|
mixlib-config (1.1.2)
|
||||||
mixlib-log (1.6.0)
|
mixlib-log (1.6.0)
|
||||||
mixlib-shellout (1.1.0)
|
mixlib-shellout (1.1.0)
|
||||||
multi_json (1.7.5)
|
multi_json (1.7.6)
|
||||||
multi_xml (0.5.3)
|
multi_xml (0.5.4)
|
||||||
multipart-post (1.2.0)
|
multipart-post (1.2.0)
|
||||||
net-http-persistent (2.8)
|
net-http-persistent (2.8)
|
||||||
net-ssh (2.6.7)
|
net-ssh (2.6.7)
|
||||||
|
@ -164,6 +164,8 @@ GEM
|
||||||
wasabi (~> 1.0)
|
wasabi (~> 1.0)
|
||||||
solve (0.4.4)
|
solve (0.4.4)
|
||||||
json
|
json
|
||||||
|
strainer (2.1.0)
|
||||||
|
berkshelf (~> 1.3)
|
||||||
systemu (2.5.2)
|
systemu (2.5.2)
|
||||||
thor (0.18.1)
|
thor (0.18.1)
|
||||||
timers (1.1.0)
|
timers (1.1.0)
|
||||||
|
@ -187,8 +189,9 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
berkshelf (~> 1.4.0)
|
berkshelf (~> 1.4.5)
|
||||||
chef (~> 11.4.4)
|
chef (~> 11.4.4)
|
||||||
chefspec (~> 1.2.0)
|
chefspec (~> 1.2.0)
|
||||||
foodcritic (~> 2.1.0)
|
foodcritic
|
||||||
json (<= 1.7.7)
|
json (<= 1.7.7)
|
||||||
|
strainer
|
||||||
|
|
13
README.md
13
README.md
|
@ -75,11 +75,15 @@ Attributes
|
||||||
Testing
|
Testing
|
||||||
=====
|
=====
|
||||||
|
|
||||||
This cookbook is using [ChefSpec](https://github.com/acrmp/chefspec) for
|
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
|
||||||
testing. Run the following before commiting. It will run your tests,
|
|
||||||
and check for lint errors.
|
|
||||||
|
|
||||||
$ ./run_tests.bash
|
Tests are defined in Strainerfile.
|
||||||
|
|
||||||
|
To run tests:
|
||||||
|
|
||||||
|
$ bundle install # install gem dependencies
|
||||||
|
$ bundle exec berks install # install cookbook dependencies
|
||||||
|
$ bundle exec strainer test # run tests
|
||||||
|
|
||||||
License and Author
|
License and Author
|
||||||
==================
|
==================
|
||||||
|
@ -97,6 +101,7 @@ License and Author
|
||||||
| **Author** | Jay Pipes (<jaypipes@att.com>) |
|
| **Author** | Jay Pipes (<jaypipes@att.com>) |
|
||||||
| **Author** | John Dewey (<jdewey@att.com>) |
|
| **Author** | John Dewey (<jdewey@att.com>) |
|
||||||
| **Author** | Abel Lopez (<al592b@att.com>) |
|
| **Author** | Abel Lopez (<al592b@att.com>) |
|
||||||
|
| **Author** | Sean Gallagher (<sean.gallagher@att.com>) |
|
||||||
| | |
|
| | |
|
||||||
| **Copyright** | Copyright (c) 2012, Rackspace US, Inc. |
|
| **Copyright** | Copyright (c) 2012, Rackspace US, Inc. |
|
||||||
| **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. |
|
| **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. |
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Strainerfile
|
||||||
|
knife test: bundle exec knife cookbook test $COOKBOOK
|
||||||
|
foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK
|
||||||
|
chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec
|
|
@ -1,19 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# A script to run tests locally before committing.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
COOKBOOK=$(awk '/^name/ {print $NF}' metadata.rb |tr -d \"\')
|
|
||||||
if [ -z $COOKBOOK ]; then
|
|
||||||
echo "Cookbook name not defined in metadata.rb"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
BUNDLE_PATH=${BUNDLE_PATH:-.bundle}
|
|
||||||
BERKSHELF_PATH=${BERKSHELF_PATH:-.cookbooks}
|
|
||||||
|
|
||||||
bundle install --path=${BUNDLE_PATH}
|
|
||||||
bundle exec berks install --path=${BERKSHELF_PATH}
|
|
||||||
bundle exec foodcritic -f any -t ~FC003 -t ~FC023 ${BERKSHELF_PATH}/${COOKBOOK}
|
|
||||||
bundle exec rspec ${BERKSHELF_PATH}/${COOKBOOK}
|
|
Loading…
Reference in New Issue