Skip to content

Commit

Permalink
Merge pull request #21 from Brainsware/rspec-puppet-facts
Browse files Browse the repository at this point in the history
"better" test coverage with rspec-puppet-facts
  • Loading branch information
igalic committed Mar 19, 2015
2 parents 748be31 + abfa14a commit aed6681
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 177 deletions.
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

0 comments on commit aed6681

Please sign in to comment.