Commit bb5bf250 authored by pwelch's avatar pwelch
Browse files

Add Additional ChefSpec Tests

Add additional ChefSpec tests for current cookbook resources.
parent 503c0bca
require 'chefspec'
require 'chefspec/berkshelf'
RSpec.configure do |config|
config.color = true # Use color in STDOUT
config.formatter = :documentation # Use the specified formatter
end
at_exit { ChefSpec::Coverage.report! }
require 'spec_helper'
describe 'erlang::esl' do
describe 'Debian Platform Family' do
cached(:chef_run_debian) do
ChefSpec::ServerRunner.new(platform: 'debian', version: '8.1')
.converge('erlang::esl')
end
it 'converges successfully' do
expect { :chef_run_debian }.to_not raise_error
end
it 'includes the apt recipe' do
expect(chef_run_debian).to include_recipe 'apt'
end
it 'adds the erlang_solutions_repo apt repository' do
expect(chef_run_debian).to add_apt_repository('erlang_solutions_repo')
end
it 'installs the esl-erlang package' do
expect(chef_run_debian).to install_package('esl-erlang')
end
end
describe 'RHEL Platform Family' do
cached(:chef_run_rhel) do
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.0')
.converge('erlang::esl')
end
it 'converges successfully' do
expect { :chef_run_rhel }.to_not raise_error
end
it 'includes the yum-erlang_solutions recipe' do
expect(chef_run_rhel).to include_recipe('yum-erlang_solutions')
end
end
end
require 'spec_helper'
describe 'erlang::package' do
describe 'Debian Platform Family' do
let(:chef_run_debian) do
ChefSpec::ServerRunner.new(platform: 'debian', version: '8.1')
end
let(:debian_converged) { chef_run_debian.converge('erlang::package') }
it 'converges successfully' do
expect { :debian_converged }.to_not raise_error
end
it 'installs the erlang.dev package' do
expect(debian_converged).to install_package('erlang-dev')
end
describe 'GUI Tools' do
context 'gui_tools is false' do
it 'installs erlang-nox package by default' do
expect(debian_converged).to install_package('erlang-nox')
end
it 'does not install erlang-x11 package' do
expect(debian_converged).to_not install_package('erlang-x11')
end
end
context 'gui_tools is true' do
it 'installs erlang-x11 package' do
chef_run_debian.node.set['erlang']['gui_tools'] = true
gui_tools_run = chef_run_debian.converge('erlang::package')
expect(gui_tools_run).to install_package('erlang-x11')
end
end
end
end
describe 'RHEL Platform Family' do
cached(:chef_run_rhel) do
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.0')
.converge('erlang::package')
end
it 'converges successfully' do
expect { :chef_run_rhel }.to_not raise_error
end
it 'includes the yum-epel recipe' do
expect(chef_run_rhel).to include_recipe('yum-epel')
end
it 'installs the erlang package' do
expect(chef_run_rhel).to install_package('erlang')
end
end
context 'RHEL 5' do
cached(:chef_run_rhel_5) do
ChefSpec::ServerRunner.new(platform: 'centos', version: '5.10')
.converge('erlang::package')
end
it 'creates the yum EPELErlangrepo repository' do
expect(chef_run_rhel_5).to create_yum_repository('EPELErlangrepo')
end
end
end
require 'spec_helper'
describe 'erlang::source' do
describe 'All Platforms' do
cached(:chef_run) { ChefSpec::ServerRunner.new.converge('erlang::source') }
it 'converges successfully' do
expect { :chef_run_rhel }.to_not raise_error
end
it 'includes the build-essential recipe' do
expect(chef_run).to include_recipe('build-essential')
end
it 'contains bash[install-erlang] with action nothing' do
execute_resource = chef_run.bash('install-erlang')
expect(execute_resource).to do_nothing
end
context 'Erlang source remote file' do
let(:erlang_source_file) { "#{Chef::Config[:file_cache_path]}/otp_src_#{chef_run.node['erlang']['source']['version']}.tar.gz" }
let(:remote_file_resource) { chef_run.remote_file(erlang_source_file) }
it 'creates a remote_file of the Erlang source code' do
expect(chef_run).to create_remote_file(erlang_source_file)
end
it 'sends a notification to the bash[install-erlang] resource' do
expect(remote_file_resource).to notify('bash[install-erlang]').immediately
end
end
end
describe 'Debian Platform Family' do
cached(:chef_run_debian) do
ChefSpec::ServerRunner.new(platform: 'debian', version: '8.1')
.converge('erlang::source')
end
%w(libncurses5-dev openssl libssl-dev).each do |pkg|
it "installs #{pkg} package" do
expect(chef_run_debian).to install_package(pkg)
end
end
end
describe 'RHEL Platform Family' do
cached(:chef_run_rhel) do
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.0')
.converge('erlang::source')
end
%w(ncurses-devel openssl-devel).each do |pkg|
it "installs #{pkg} package" do
expect(chef_run_rhel).to install_package(pkg)
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment