diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 000000000..74ce67fb4 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,3 @@ +fixtures: + repositories: + stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib" diff --git a/.gemfile b/.gemfile new file mode 100644 index 000000000..b17ef437b --- /dev/null +++ b/.gemfile @@ -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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..ed76831d9 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..e47b27c58 --- /dev/null +++ b/Rakefile @@ -0,0 +1,2 @@ +require 'rake' +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/manifests/client/install.pp b/manifests/client/install.pp index 521103bd6..86771d770 100644 --- a/manifests/client/install.pp +++ b/manifests/client/install.pp @@ -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, } } } diff --git a/manifests/server/install.pp b/manifests/server/install.pp index 2cd3cd1a3..58b5ca1d3 100644 --- a/manifests/server/install.pp +++ b/manifests/server/install.pp @@ -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, } } } diff --git a/manifests/site.pp b/manifests/site.pp new file mode 100644 index 000000000..e69de29bb diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb new file mode 100644 index 000000000..cabe803d4 --- /dev/null +++ b/spec/classes/client_spec.rb @@ -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 diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb new file mode 100644 index 000000000..fb0a16f04 --- /dev/null +++ b/spec/classes/server_spec.rb @@ -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 diff --git a/spec/fixtures/modules/ssh/files b/spec/fixtures/modules/ssh/files new file mode 120000 index 000000000..84dafe8de --- /dev/null +++ b/spec/fixtures/modules/ssh/files @@ -0,0 +1 @@ +../../../../files \ No newline at end of file diff --git a/spec/fixtures/modules/ssh/lib b/spec/fixtures/modules/ssh/lib new file mode 120000 index 000000000..42892ea04 --- /dev/null +++ b/spec/fixtures/modules/ssh/lib @@ -0,0 +1 @@ +../../../../lib \ No newline at end of file diff --git a/spec/fixtures/modules/ssh/manifests b/spec/fixtures/modules/ssh/manifests new file mode 120000 index 000000000..373b99206 --- /dev/null +++ b/spec/fixtures/modules/ssh/manifests @@ -0,0 +1 @@ +../../../../manifests \ No newline at end of file diff --git a/spec/fixtures/modules/ssh/templates b/spec/fixtures/modules/ssh/templates new file mode 120000 index 000000000..f8a06d1d1 --- /dev/null +++ b/spec/fixtures/modules/ssh/templates @@ -0,0 +1 @@ +../../../../templates \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a4aeeae23..6e1d96819 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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' diff --git a/tests/init.pp b/tests/init.pp index 13a463808..1c7d29f18 100644 --- a/tests/init.pp +++ b/tests/init.pp @@ -1 +1 @@ -include ssh +class {"::ssh::server": } diff --git a/tests/server.pp b/tests/server.pp new file mode 100644 index 000000000..112640ec0 --- /dev/null +++ b/tests/server.pp @@ -0,0 +1 @@ +include ssh::server