module-puppetlabs-mysql/spec/defines/mysql_db_spec.rb
Ashley Penney 00a191f9ed Convert specs to RSpec 2.99.1 syntax with Transpec
This conversion is done by Transpec 2.3.6 with the following command:
    transpec -f -c "bundle exec rake spec"

* 69 conversions
    from: it { should ... }
      to: it { is_expected.to ... }

* 48 conversions
    from: obj.should
      to: expect(obj).to

* 34 conversions
    from: == expected
      to: eq(expected)

* 4 conversions
    from: it { should_not ... }
      to: it { is_expected.not_to ... }

* 3 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 2 conversions
    from: lambda { }.should
      to: expect { }.to

* 2 conversions
    from: pending
      to: skip

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-08-08 16:47:44 -04:00

56 lines
2 KiB
Ruby

require 'spec_helper'
describe 'mysql::db', :type => :define do
let(:facts) {{ :osfamily => 'RedHat' }}
let(:title) { 'test_db' }
let(:params) {
{ 'user' => 'testuser',
'password' => 'testpass',
}
}
it 'should report an error when ensure is not present or absent' do
params.merge!({'ensure' => 'invalid_val'})
expect { subject }.to raise_error(Puppet::Error,
/invalid_val is not supported for ensure\. Allowed values are 'present' and 'absent'\./)
end
it 'should not notify the import sql exec if no sql script was provided' do
is_expected.to contain_mysql_database('test_db').without_notify
end
it 'should subscribe to database if sql script is given' do
params.merge!({'sql' => 'test_sql'})
is_expected.to contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]')
end
it 'should only import sql script on creation if not enforcing' do
params.merge!({'sql' => 'test_sql', 'enforce_sql' => false})
is_expected.to contain_exec('test_db-import').with_refreshonly(true)
end
it 'should import sql script on creation if enforcing' do
params.merge!({'sql' => 'test_sql', 'enforce_sql' => true})
is_expected.to contain_exec('test_db-import').with_refreshonly(false)
end
it 'should not create database and database user' do
params.merge!({'ensure' => 'absent', 'host' => 'localhost'})
is_expected.to contain_mysql_database('test_db').with_ensure('absent')
is_expected.to contain_mysql_user('testuser@localhost').with_ensure('absent')
end
it 'should create with an appropriate collate and charset' do
params.merge!({'charset' => 'utf8', 'collate' => 'utf8_danish_ci'})
is_expected.to contain_mysql_database('test_db').with({
'charset' => 'utf8',
'collate' => 'utf8_danish_ci',
})
end
it 'should use dbname parameter as database name instead of name' do
params.merge!({'dbname' => 'real_db'})
is_expected.to contain_mysql_database('real_db')
end
end