Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"better" test coverage with rspec-puppet-facts #21

Merged
merged 1 commit into from
Mar 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,102 @@
"name": "maestrodev-wget",
"version_requirement": ">= 1.2.0 <= 2.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"4",
"5",
"6",
"7"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"4",
"5",
"6",
"7"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"4",
"5",
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"4",
"5",
"6",
"7"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"11 SP1"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"10.04",
"12.04",
"14.04"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"10",
"11"
]
},
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
"Server 2003",
"Server 2003 R2",
"Server 2008",
"Server 2008 R2",
"Server 2012",
"Server 2012 R2",
"7",
"8"
]
},
{
"operatingsystem": "AIX",
"operatingsystemrelease": [
"5.3",
"6.1",
"7.1"
]
}
],
"requirements": [
{
"name": "pe",
"version_requirement": "3.3.x"
},
{
"name": "puppet",
"version_requirement": ">=2.7.20 <4.0.0"
}
]
}
258 changes: 132 additions & 126 deletions spec/classes/composer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,131 +15,137 @@
require 'spec_helper'

describe 'composer', :type => :class do
let(:facts) {{
:kernel => 'Linux',
:path => '/bin:/usr/bin',
:http_proxy => 'http://proxy:1000',
:https_proxy => 'http://proxy:1000',
}}
let(:title) { 'composer' }

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/local/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('root') \
.with_cwd('/usr/local/bin')
}

it { is_expected.not_to contain_exec('composer-update') }

describe 'with a given target_dir' do
let(:params) {{ :target_dir => '/usr/bin' }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('root') \
.with_cwd('/usr/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

describe 'with a given command_name' do
let(:params) {{ :command_name => 'c' }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/local/bin/c')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x c') \
.with_user('root') \
.with_cwd('/usr/local/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

describe 'with auto_update => true' do
let(:params) {{ :auto_update => true }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/local/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('root') \
.with_cwd('/usr/local/bin')
}

it { is_expected.to contain_exec('composer-update') \
.with_command('composer self-update') \
.with_user('root') \
.with_path('/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin')
}
end

describe 'with a given user' do
let(:params) {{ :user => 'will' }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('will') \
.with_destination('/usr/local/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('will') \
.with_cwd('/usr/local/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

describe 'with provider set to package' do
let(:params) {{ :provider => 'package' }}

it { is_expected.not_to contain_wget__fetch('composer-install') }
it { is_expected.to contain_package('composer-install') \
.with_name('php-composer') \
.with_ensure('present')
}
end

describe 'with provider package, and auto_update' do
let(:params) {{ :provider => 'package', :auto_update => true }}

it { is_expected.not_to contain_wget__fetch('composer-install') }
it { is_expected.to contain_package('composer-install') \
.with_name('php-composer') \
.with_ensure('latest')
}
end

describe 'with provider package, and custom package name' do
let(:params) {{ :provider => 'package', :package => 'php5-composer' }}

it { is_expected.not_to contain_wget__fetch('composer-install') }
it { is_expected.to contain_package('composer-install') \
.with_name('php5-composer') \
.with_ensure('present')
}
context 'supported operating systems' do
on_supported_os.each do |os, facts|
context "on #{os} #{facts}" do
let(:facts) do
facts
end

context 'it should install composer' do
let(:title) { 'composer' }

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/local/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('root') \
.with_cwd('/usr/local/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

context 'with a given target_dir' do
let(:params) {{ :target_dir => '/usr/bin' }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('root') \
.with_cwd('/usr/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

context 'with a given command_name' do
let(:params) {{ :command_name => 'c' }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/local/bin/c')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x c') \
.with_user('root') \
.with_cwd('/usr/local/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

context 'with auto_update => true' do
let(:params) {{ :auto_update => true }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('root') \
.with_destination('/usr/local/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('root') \
.with_cwd('/usr/local/bin')
}

it { is_expected.to contain_exec('composer-update') \
.with_command('composer self-update') \
.with_user('root') \
.with_path('/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin')
}
end

context 'with a given user' do
let(:params) {{ :user => 'will' }}

it { is_expected.to contain_wget__fetch('composer-install') \
.with_source('https://getcomposer.org/composer.phar') \
.with_execuser('will') \
.with_destination('/usr/local/bin/composer')
}

it { is_expected.to contain_exec('composer-fix-permissions') \
.with_command('chmod a+x composer') \
.with_user('will') \
.with_cwd('/usr/local/bin')
}

it { is_expected.not_to contain_exec('composer-update') }
end

context 'with provider set to package' do
let(:params) {{ :provider => 'package' }}

it { is_expected.not_to contain_wget__fetch('composer-install') }
it { is_expected.to contain_package('composer-install') \
.with_name('php-composer') \
.with_ensure('present')
}
end

context 'with provider package, and auto_update' do
let(:params) {{ :provider => 'package', :auto_update => true }}

it { is_expected.not_to contain_wget__fetch('composer-install') }
it { is_expected.to contain_package('composer-install') \
.with_name('php-composer') \
.with_ensure('latest')
}
end

context 'with provider package, and custom package name' do
let(:params) {{ :provider => 'package', :package => 'php5-composer' }}

it { is_expected.not_to contain_wget__fetch('composer-install') }
it { is_expected.to contain_package('composer-install') \
.with_name('php5-composer') \
.with_ensure('present')
}
end
end
end
end
end
Loading