README.md in minitest-chef-handler-0.3.0 vs README.md in minitest-chef-handler-0.4.0
- old
+ new
@@ -15,20 +15,22 @@
$ gem install minitest-chef-handler
```
## Usage
-1. Add the report handler to your client.rb or solo.rb file:
+Add the report handler to your client.rb or solo.rb file:
```ruby
require 'minitest-chef-handler'
report_handlers << MiniTest::Chef::Handler.new
```
-2. Write your tests as normal MiniTest cases extending from MiniTest::Chef::TestCase:
+### Test cases
+Write your tests as normal MiniTest cases extending from MiniTest::Chef::TestCase:
+
```ruby
class TestNginx < MiniTest::Chef::TestCase
def test_config_file_exist
assert File.exist?('/etc/nginx.conf')
end
@@ -42,9 +44,63 @@
def test_succeed
assert run_status.success?
end
end
```
+
+### Spec cases
+
+Wrap your descriptions with a class extending from MiniTest::Chef::Spec:
+
+```ruby
+class NginxSpec < MiniTest::Chef::Spec
+ describe 'configuration' do
+ it 'creates nginx.conf'
+ end
+end
+```
+
+Use the prefix `recipe::` in your descriptions:
+
+```ruby
+describe "recipe::nginx::configuration" do
+ it 'creates nginx.conf'
+end
+```
+
+Or use `describe_recipe` to define your specs:
+
+```ruby
+describe_recipe "nginx::configuration" do
+ it 'creates nginx.conf'
+end
+```
+
+You still have access to Chef's `run_status`, `node` and `run_context` from your specs:
+
+```ruby
+describe_recipe 'nginx:configuration' do
+ it 'installs version 1.0.15' do
+ node[:nginx][:version].should == '1.0.15'
+ end
+end
+```
+
+### Custom assertions
+
+By including `MiniTest::Chef::Resources` and `MiniTest::Chef::Assertions` you
+can also make assertions like these:
+
+```ruby
+file("/etc/fstab").must_have(:mode, "644")
+package("less").must_be_installed
+service("chef-client").must_be_running
+```
+
+The resources supported are: `cron`, `directory`, `file`, `group`, `ifconfig`,
+`link`, `mount`, `package`, `service` and `user`.
+
+For example usage see the tests under the `examples/spec_examples` directory.
## Further configuration
These are the options the handler accepts: