No description, website, or topics provided.
Pull request Compare This branch is 162 commits behind btm:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
attributes
recipes
test/support
.travis.yml
CHANGELOG.md
LICENSE
README.md
Rakefile
metadata.rb

README.md

Cookbook: minitest-handler
Author: Bryan McLellan btm@loftninjas.org
Author: Bryan W. Berry bryan.berry@gmail.com
Author: David Petzel davidpetzel@gmail.com Copyright: 2012 Opscode, Inc.
License: Apache 2.0

Description

minitest-handler Build Status

This cookbook utilizes the minitest-chef-handler project to facilitate cookbook testing.

minitest-chef-handler project: https://github.com/calavera/minitest-chef-handler
stable minitest-handler cookbook: http://community.opscode.com/cookbooks/minitest-handler
minitest-handler cookbook development: https://github.com/btm/minitest-handler-cookbook

Attributes

  • node[:minitest][:path] - Location to store and find tests, defaults to /var/chef/minitest
  • node[:minitest][:tests] - Test files to run, defaults to **/*_test.rb

Usage

  • The node run list should begin with 'recipe[minitest-handler]'
  • Each cookbook should contain tests in the 'files/default/tests/minitest' directory with a file suffix of '_test.rb'

Minitest: https://github.com/seattlerb/minitest

Examples

Tradition minitest

class TestApache2 < MiniTest::Chef::TestCase
  def test_that_the_package_installed
    case node[:platform]
    when "ubuntu","debian"
      assert system('apt-cache policy apache2 | grep Installed | grep -v none')
    end
  end

  def test_that_the_service_is_running
    assert system('/etc/init.d/apache2 status')
  end

  def test_that_the_service_is_enabled
    assert File.exists?(Dir.glob("/etc/rc5.d/S*apache2").first)
  end
end

Using minitest/spec

require 'minitest/spec'

describe_recipe 'ark::test' do

  # It's often convenient to load these includes in a separate
  # helper along with
  # your own helper methods, but here we just include them directly:
  include MiniTest::Chef::Assertions
  include MiniTest::Chef::Context
  include MiniTest::Chef::Resources

  it "installed the unzip package" do
    package("unzip").must_be_installed
  end

  it "dumps the correct files into place with correct owner and group" do
    file("/usr/local/foo_dump/foo1.txt").must_have(:owner, "foobarbaz").and(:group, "foobarbaz")
  end

 end

For more detailed examples, see here