Skip to content

Commit

Permalink
Convert specs to RSpec 2.99.1 syntax with Transpec
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ashley Penney committed Aug 8, 2014
1 parent 314dc1f commit 00a191f
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 190 deletions.
2 changes: 1 addition & 1 deletion spec/classes/graceful_failures_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let(:facts) { facts }

context 'should gracefully fail' do
it { expect { should compile}.to raise_error(Puppet::Error, /Unsupported platform:/) }
it { expect { is_expected.to compile}.to raise_error(Puppet::Error, /Unsupported platform:/) }
end
end
end
Expand Down
92 changes: 24 additions & 68 deletions spec/classes/mysql_bindings_spec.rb
Original file line number Diff line number Diff line change
@@ -1,74 +1,30 @@
require 'spec_helper'

describe 'mysql::bindings' do
let(:params) {{
'java_enable' => true,
'perl_enable' => true,
'php_enable' => true,
'python_enable' => true,
'ruby_enable' => true,
'client_dev' => true,
'daemon_dev' => true,
}}

shared_examples 'bindings' do |osfamily, operatingsystem, operatingsystemrelease, java_name, perl_name, php_name, python_name, ruby_name, client_dev_name, daemon_dev_name|
let :facts do
{ :osfamily => osfamily, :operatingsystem => operatingsystem,
:operatingsystemrelease => operatingsystemrelease, :root_home => '/root',
}
end
it { should contain_package('mysql-connector-java').with(
:name => java_name,
:ensure => 'present'
)}
it { should contain_package('perl_mysql').with(
:name => perl_name,
:ensure => 'present'
)}
it { should contain_package('python-mysqldb').with(
:name => python_name,
:ensure => 'present'
)}
it { should contain_package('ruby_mysql').with(
:name => ruby_name,
:ensure => 'present'
)}
if client_dev_name
it { should contain_package('mysql-client_dev').with(
:name => client_dev_name,
:ensure => 'present'
)}
on_pe_supported_platforms(PLATFORMS).each do |pe_version,pe_platforms|
pe_platforms.each do |pe_platform,facts|
describe "on #{pe_version} #{pe_platform}" do
let(:facts) { facts }

let(:params) {{
'java_enable' => true,
'perl_enable' => true,
'php_enable' => true,
'python_enable' => true,
'ruby_enable' => true,
'client_dev' => true,
'daemon_dev' => true,
'client_dev_package_name' => 'libmysqlclient-devel',
'daemon_dev_package_name' => 'mysql-devel',
}}

it { is_expected.to contain_package('mysql-connector-java') }
it { is_expected.to contain_package('perl_mysql') }
it { is_expected.to contain_package('python-mysqldb') }
it { is_expected.to contain_package('ruby_mysql') }
it { is_expected.to contain_package('mysql-client_dev') }
it { is_expected.to contain_package('mysql-daemon_dev') }
end
end
if daemon_dev_name
it { should contain_package('mysql-daemon_dev').with(
:name => daemon_dev_name,
:ensure => 'present'
)}
end
end

context 'Debian' do
it_behaves_like 'bindings', 'Debian', 'Debian', '7.4','libmysql-java', 'libdbd-mysql-perl', 'php5-mysql', 'python-mysqldb', 'libmysql-ruby', 'libmysqlclient-dev', 'libmysqld-dev'
it_behaves_like 'bindings', 'Debian', 'Ubuntu', '14.04', 'libmysql-java', 'libdbd-mysql-perl', 'php5-mysql', 'python-mysqldb', 'libmysql-ruby', 'libmysqlclient-dev', 'libmysqld-dev'
end

context 'freebsd' do
it_behaves_like 'bindings', 'FreeBSD', 'FreeBSD', '10.0', 'databases/mysql-connector-java', 'p5-DBD-mysql', 'databases/php5-mysql', 'databases/py-MySQLdb', 'databases/ruby-mysql'
end

context 'redhat' do
it_behaves_like 'bindings', 'RedHat', 'RedHat', '6.5', 'mysql-connector-java', 'perl-DBD-MySQL', 'php-mysql', 'MySQL-python', 'ruby-mysql', nil, 'mysql-devel'
it_behaves_like 'bindings', 'RedHat', 'OpenSuSE', '11.3', 'mysql-connector-java', 'perl-DBD-MySQL', 'php-mysql', 'MySQL-python', 'ruby-mysql', nil, 'mysql-devel'
end

describe 'on any other os' do
let :facts do
{:osfamily => 'foo', :root_home => '/root'}
end

it 'should fail' do
expect { subject }.to raise_error(/Unsupported platform:/)
end
end

end
8 changes: 4 additions & 4 deletions spec/classes/mysql_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
let(:facts) { facts }

context 'with defaults' do
it { should_not contain_class('mysql::bindings') }
it { should contain_package('mysql_client') }
it { is_expected.not_to contain_class('mysql::bindings') }
it { is_expected.to contain_package('mysql_client') }
end

context 'with bindings enabled' do
let(:params) {{ :bindings_enable => true }}

it { should contain_class('mysql::bindings') }
it { should contain_package('mysql_client') }
it { is_expected.to contain_class('mysql::bindings') }
it { is_expected.to contain_package('mysql_client') }
end
end
end
Expand Down
18 changes: 9 additions & 9 deletions spec/classes/mysql_server_account_security_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@
let(:facts) { facts.merge({:fqdn => 'myhost.mydomain', :hostname => 'myhost'}) }

it 'should remove Mysql_User[[email protected]]' do
should contain_mysql_user('[email protected]').with_ensure('absent')
is_expected.to contain_mysql_user('[email protected]').with_ensure('absent')
end
it 'should remove Mysql_User[root@myhost]' do
should contain_mysql_user('root@myhost').with_ensure('absent')
is_expected.to contain_mysql_user('root@myhost').with_ensure('absent')
end
it 'should remove Mysql_User[[email protected]]' do
should contain_mysql_user('[email protected]').with_ensure('absent')
is_expected.to contain_mysql_user('[email protected]').with_ensure('absent')
end
it 'should remove Mysql_User[root@::1]' do
should contain_mysql_user('root@::1').with_ensure('absent')
is_expected.to contain_mysql_user('root@::1').with_ensure('absent')
end
it 'should remove Mysql_User[@myhost.mydomain]' do
should contain_mysql_user('@myhost.mydomain').with_ensure('absent')
is_expected.to contain_mysql_user('@myhost.mydomain').with_ensure('absent')
end
it 'should remove Mysql_User[@myhost]' do
should contain_mysql_user('@myhost').with_ensure('absent')
is_expected.to contain_mysql_user('@myhost').with_ensure('absent')
end
it 'should remove Mysql_User[@localhost]' do
should contain_mysql_user('@localhost').with_ensure('absent')
is_expected.to contain_mysql_user('@localhost').with_ensure('absent')
end
it 'should remove Mysql_User[@%]' do
should contain_mysql_user('@%').with_ensure('absent')
is_expected.to contain_mysql_user('@%').with_ensure('absent')
end

it 'should remove Mysql_database[test]' do
should contain_mysql_database('test').with_ensure('absent')
is_expected.to contain_mysql_database('test').with_ensure('absent')
end
end
end
Expand Down
24 changes: 12 additions & 12 deletions spec/classes/mysql_server_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
context 'standard conditions' do
let(:params) { default_params }

it { should contain_mysql_user('testuser@localhost').with(
it { is_expected.to contain_mysql_user('testuser@localhost').with(
:require => 'Class[Mysql::Server::Root_password]'
)}

it { should contain_mysql_grant('testuser@localhost/*.*').with(
it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with(
:privileges => ["SELECT", "RELOAD", "LOCK TABLES", "SHOW VIEW", "PROCESS"]
)}

it { should contain_cron('mysql-backup').with(
it { is_expected.to contain_cron('mysql-backup').with(
:command => '/usr/local/sbin/mysqlbackup.sh',
:ensure => 'present'
)}

it { should contain_file('mysqlbackup.sh').with(
it { is_expected.to contain_file('mysqlbackup.sh').with(
:path => '/usr/local/sbin/mysqlbackup.sh',
:ensure => 'present'
) }

it { should contain_file('mysqlbackupdir').with(
it { is_expected.to contain_file('mysqlbackupdir').with(
:path => '/tmp',
:ensure => 'directory'
)}
Expand All @@ -55,11 +55,11 @@

it 'should have 25 days of rotation' do
# MySQL counts from 0 I guess.
should contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/)
is_expected.to contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/)
end

it 'should have a standard PATH' do
should contain_file('mysqlbackup.sh').with_content(%r{PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin})
is_expected.to contain_file('mysqlbackup.sh').with_content(%r{PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin})
end
end

Expand All @@ -71,7 +71,7 @@
}.merge(default_params)
end

it { should contain_file('mysqlbackupdir').with(
it { is_expected.to contain_file('mysqlbackupdir').with(
:path => '/tmp',
:ensure => 'directory',
:mode => '0750',
Expand All @@ -85,7 +85,7 @@
{ :backupcompress => false }.merge(default_params)
end

it { should contain_file('mysqlbackup.sh').with(
it { is_expected.to contain_file('mysqlbackup.sh').with(
:path => '/usr/local/sbin/mysqlbackup.sh',
:ensure => 'present'
) }
Expand All @@ -102,7 +102,7 @@
{ :ignore_events => false }.merge(default_params)
end

it { should contain_file('mysqlbackup.sh').with(
it { is_expected.to contain_file('mysqlbackup.sh').with(
:path => '/usr/local/sbin/mysqlbackup.sh',
:ensure => 'present'
) }
Expand All @@ -120,14 +120,14 @@
{ :backupdatabases => ['mysql'] }.merge(default_params)
end

it { should contain_file('mysqlbackup.sh').with(
it { is_expected.to contain_file('mysqlbackup.sh').with(
:path => '/usr/local/sbin/mysqlbackup.sh',
:ensure => 'present'
) }

it 'should have a backup file for each database' do
content = subject.resource('file','mysqlbackup.sh').send(:parameters)[:content]
content.should match(' mysql | bzcat -zc \${DIR}\\\${PREFIX}mysql_`date')
expect(content).to match(' mysql | bzcat -zc \${DIR}\\\${PREFIX}mysql_`date')
# verify_contents(subject, 'mysqlbackup.sh', [
# ' mysql | bzcat -zc ${DIR}/${PREFIX}mysql_`date +%Y%m%d-%H%M%S`.sql',
# ])
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/mysql_server_monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
default_params
end

it { should contain_mysql_user('monitoruser@monitorhost')}
it { is_expected.to contain_mysql_user('monitoruser@monitorhost')}

it { should contain_mysql_grant('monitoruser@monitorhost/*.*').with(
it { is_expected.to contain_mysql_grant('monitoruser@monitorhost/*.*').with(
:ensure => 'present',
:user => 'monitoruser@monitorhost',
:table => '*.*',
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mysql_server_mysqltuner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe "on #{pe_version} #{pe_platform}" do
let(:facts) { facts }

it { should contain_file('/usr/local/bin/mysqltuner') }
it { is_expected.to contain_file('/usr/local/bin/mysqltuner') }
end
end
end
Expand Down
Loading

0 comments on commit 00a191f

Please sign in to comment.