double-z
1/7/2014 - 5:28 AM

01-Gemfile.rb

knife:       bundle exec knife cookbook test $COOKBOOK
foodcritic:  bundle exec foodcritic $SANDBOX/$COOKBOOK -f any
rspec:       (cd $COOKBOOK && bundle exec rspec --color --format documentation)
kitchen:     (cd $COOKBOOK && bundle exec kitchen test)
---
driver_plugin: lxc
driver_config:
  use_sudo: true

platforms:
  - name: ubuntu-12.04
    driver_config:
      base_container: ubuntu_12.04
      username: ubuntu
      password: ubuntu

suites:
- name: default
  run_list: ["recipe[myface]"]
  attributes: {}
<html>
  <head>
    <title>Welcome to <%= node['fqdn'] %></title>
  </head>

  <body>
    <p>Here's everything you need to know about <%= node['fqdn'] %>:</p>
    <pre><%= JSON.pretty_generate(node.to_hash) %></pre>
  </body>
</html>
package 'apache2'

service 'apache2' do
  action [:enable, :start]
end

template '/var/www/index.html' do
  owner   'root'
  group   'root'
  mode    '0755'
  source  'index.html.erb'
end
require 'spec_helper'
 
# Replace USERNAME with your username!
describe 'USERNAME-myface::default' do
  let(:chef_run) do
    run = ChefSpec::ChefRunner.new(platform: 'ubuntu', version: '12.04')
    run.converge('USERNAME-myface::default')
  end
 
  it 'installs apache2' do
    expect(chef_run).to install_package('apache2')
  end
 
  it 'starts the apache2 service' do
    expect(chef_run).to start_service('apache2')
  end
  
  it 'sets apache2 to start on boot' do
    expect(chef_run).to set_service_to_start_on_boot 'apache2'
  end
  
  it 'creates the default template' do
    expect(chef_run).to create_file('/var/www/index.html')
  end
  
  it 'creates the site with the correct content' do
    template = chef_run.template('/var/www/index.html')
    expect(template.owner).to eq('root')
    expect(template.group).to eq('root')
  end
end
bundle install --path /var/lib/jenkins/support/vendor
bundle exec strainer test
package 'apache2'

service 'apache2' do
  action [:enable, :start]
end
knife:       bundle exec knife cookbook test $COOKBOOK
foodcritic:  bundle exec foodcritic $SANDBOX/$COOKBOOK -f any
rspec:       (cd $COOKBOOK && bundle exec rspec --color --format documentation)
guard :rspec, cli: '--color', all_on_start: false do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{recipes/(.+)\.rb$})     { |m| "spec/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { 'spec' }
end

guard :foodcritic, cookbook_paths: '.', all_on_start: false do
  watch(%r{attributes/.+\.rb$})
  watch(%r{providers/.+\.rb$})
  watch(%r{recipes/.+\.rb$})
  watch(%r{resources/.+\.rb$})
end
require 'spec_helper'

# Replace USERNAME with your username!
describe 'USERNAME-myface::default' do
  let(:chef_run) do
    run = ChefSpec::ChefRunner.new(platform: 'ubuntu', version: '12.04')
    run.converge('USERNAME-myface::default')
  end

  it 'installs apache2' do
    expect(chef_run).to install_package('apache2')
  end

  it 'starts the apache2 service' do
    expect(chef_run).to start_service('apache2')
  end
  
  it 'sets apache2 to start on boot' do
    expect(chef_run).to set_service_to_start_on_boot 'apache2'
  end
end
source 'https://rubygems.org'
group :test do
  gem 'chefspec',         '~> 1.3'
  gem 'foodcritic',       '~> 2.1'
  gem 'strainer',         '~> 3.0'
  gem 'test-kitchen',     '~> 1.0.0.alpha'
  gem 'kitchen-lxc',      '~> 0.0.1.beta1'
  gem 'knife-spork',      '~> 1.0.17'
  gem 'hipchat',          '~> 0.10.0'

  gem 'guard',            '~> 1.8'
  gem 'guard-foodcritic', '~> 1.0'
  gem 'guard-rspec',      '~> 3.0'
end