Skip to content

Commit

Permalink
Merge pull request redhat-openstack#23 from CyBeRoni/master
Browse files Browse the repository at this point in the history
Really make $ensure variable
  • Loading branch information
saz committed Mar 8, 2014
2 parents 58c4944 + 5ff3d28 commit 3e6f851
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"
16 changes: 16 additions & 0 deletions .gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source 'https://rubygems.org'

gem 'puppetlabs_spec_helper', '>= 0.1.0', :require => false

if puppetversion = ENV['PUPPET_VERSION']
gem 'puppet', puppetversion, :require => false

if puppetversion[0].chr.to_i < 3
gem 'hiera-puppet', :require => false
end

else
gem 'puppet', :require => false
end

# vim:ft=ruby
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: ruby
rvm:
- 1.8.7
- 1.9.3
script: 'rake spec'
env:
- PUPPET_VERSION="~> 2.7.0"
- PUPPET_VERSION="3.3"
gemfile: .gemfile
branches:
only:
- master
notifications:
email: false
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'rake'
require 'puppetlabs_spec_helper/rake_tasks'
6 changes: 2 additions & 4 deletions manifests/client/install.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
class ssh::client::install (
$ensure = present
) inherits ssh::params {
class ssh::client::install {
if $ssh::params::client_package_name {
if !defined(Package[$ssh::params::client_package_name]) {
package { $ssh::params::client_package_name:
ensure => $ensure,
ensure => $ssh::client::ensure,
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions manifests/server/install.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
class ssh::server::install (
$ensure = present
) inherits ssh::params {
class ssh::server::install {
include ssh::params
if $ssh::params::server_package_name {
if !defined(Package[$ssh::params::server_package_name]) {
package { $ssh::params::server_package_name:
ensure => $ensure,
ensure => $ssh::server::ensure,
}
}
}
Expand Down
Empty file added manifests/site.pp
Empty file.
33 changes: 33 additions & 0 deletions spec/classes/client_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper'

describe 'ssh::client', :type => 'class' do
context "On Debian with no other parameters" do
let :facts do
{
:osfamily => 'Debian',
:interfaces => 'eth0',
:ipaddress_eth0 => '192.168.1.1'
}
end
it {
should contain_package('openssh-client').with(:ensure => 'present')
}
end
context "On Debian with custom ensure" do
let :facts do
{
:osfamily => 'Debian',
:interfaces => 'eth0',
:ipaddress_eth0 => '192.168.1.1'
}
end
let :params do
{
:ensure => 'latest'
}
end
it {
should contain_package('openssh-client').with(:ensure => 'latest')
}
end
end
33 changes: 33 additions & 0 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper'

describe 'ssh::server', :type => 'class' do
context "On Debian with no other parameters" do
let :facts do
{
:osfamily => 'Debian',
:interfaces => 'eth0',
:ipaddress_eth0 => '192.168.1.1'
}
end
it {
should contain_package('openssh-server').with(:ensure => 'present')
}
end
context "On Debian with custom ensure" do
let :facts do
{
:osfamily => 'Debian',
:interfaces => 'eth0',
:ipaddress_eth0 => '192.168.1.1'
}
end
let :params do
{
:ensure => 'latest'
}
end
it {
should contain_package('openssh-server').with(:ensure => 'latest')
}
end
end
1 change: 1 addition & 0 deletions spec/fixtures/modules/ssh/files
1 change: 1 addition & 0 deletions spec/fixtures/modules/ssh/lib
1 change: 1 addition & 0 deletions spec/fixtures/modules/ssh/manifests
1 change: 1 addition & 0 deletions spec/fixtures/modules/ssh/templates
20 changes: 2 additions & 18 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
require 'pathname'
dir = Pathname.new(__FILE__).parent
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')

require 'mocha'
require 'puppet'
gem 'rspec', '=1.2.9'
require 'spec/autorun'

Spec::Runner.configure do |config|
config.mock_with :mocha
end

# We need this because the RAL uses 'should' as a method. This
# allows us the same behaviour but with a different method name.
class Object
alias :must :should
end
require 'rspec-puppet'
require 'puppetlabs_spec_helper/module_spec_helper'
2 changes: 1 addition & 1 deletion tests/init.pp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ssh
class {"::ssh::server": }
1 change: 1 addition & 0 deletions tests/server.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ssh::server

0 comments on commit 3e6f851

Please sign in to comment.