Skip to content

Instantly share code, notes, and snippets.

@micgo
Forked from charlesjohnson/database_test.rb
Last active December 20, 2015 23:09
Show Gist options
  • Save micgo/6210658 to your computer and use it in GitHub Desktop.
Save micgo/6210658 to your computer and use it in GitHub Desktop.
require File.expand_path('../support/helpers', __FILE__)
describe 'myface::database' do
include Helpers::Myface
# Example spec tests can be found at http://git.io/Fahwsw
# Verify that MySQL is installed & enabled:
it "Enables and starts the mysql daemon" do
service("mysqld").must_be_running
service("mysqld").must_be_enabled
end
# Verify that the myface database has a user table:
it "Seeds the myface database" do
myface_tables.must_include "users"
end
end
require 'chefspec'
require 'spec_helper'
describe 'myface::default' do
let (:chef_run) do
runner = ChefSpec::ChefRunner.new(
platform: 'centos',
version: '6.3'
)
runner.node.normal['mysql']['server_root_password'] = 'rootpass'
runner.node.normal['mysql']['server_debian_password'] = 'debpass'
runner.node.normal['mysql']['server_repl_password'] = 'replpass'
runner.converge('myface::default')
end
end
require File.expand_path('../support/helpers', __FILE__)
describe 'myface::default' do
include Helpers::Myface
# Example spec tests can be found at http://git.io/Fahwsw
# it 'runs no tests by default' do
# end
end
require 'chefspec'
require 'spec_helper'
describe 'myface::webserver' do
let (:chef_run) do
runner = ChefSpec::ChefRunner.new(
platform: 'centos',
version: '6.3'
)
runner.node.normal['mysql']['server_root_password'] = 'rootpass'
runner.node.normal['mysql']['server_debian_password'] = 'debpass'
runner.node.normal['mysql']['server_repl_password'] = 'replpass'
runner.converge('myface::webserver')
end
# Check that php-mysql is installed
it 'should install the php-mysql package' do
expect(chef_run).to install_package 'php-mysql'
end
# Check to make sure myface configuration is created
it 'should create the myface apache configuration' do
expect(chef_run).to create_file '/etc/httpd/sites-available/myface.conf'
end
# Check for myface site directory and index file
it 'should deploy the myface index page' do
expect(chef_run).to create_directory '/srv/apache/myface'
directory = chef_run.directory('/srv/apache/myface')
expect(directory.mode).to eq("0755")
expect(chef_run).to create_file '/srv/apache/myface/index.php'
file = chef_run.template('/srv/apache/myface/index.php')
expect(file.mode).to eq("0644")
end
end
require File.expand_path('../support/helpers', __FILE__)
require File.expand_path('../../apache2/support/helpers', __FILE__)
describe 'myface::webserver' do
include Helpers::Myface
include Helpers::Apache
# Example spec tests can be found at http://git.io/Fahwsw
# Verify that Apache is installed and running:
it "Enables and starts the httpd daemon" do
service("httpd").must_be_running
service("httpd").must_be_enabled
end
# Verify that mod_php is installed for apache:
it "enables mod_php5" do
apache_enabled_modules.must_include "php5_module"
end
# Verify that the myface apache config file has been enabled:
it "configures apache for myface" do
link("#{node['apache']['dir']}/sites-enabled/myface.conf").must_exist.with(:link_type, :symbolic).and(:to, "#{node['apache']['dir']}/sites-available/myface.conf")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment