diff --git a/.fixtures.yml b/.fixtures.yml index 7fa5bb4..1935861 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,10 +1,13 @@ fixtures: repositories: - "puppi": "git://github.com/example42/puppi.git" - "monitor": "git://github.com/example42/puppet-monitor.git" - "firewall": "git://github.com/example42/puppet-firewall.git" - "iptables": "git://github.com/example42/puppet-iptables.git" - "concat": "git://github.com/example42/puppet-concat.git" + stdlib: + repo: 'https://github.com/puppetlabs/puppetlabs-stdlib.git' + ref: '4.6.0' + common: + repo: 'https://github.com/ghoneycutt/puppet-module-common.git' + ref: 'v1.4.1' + firewall: + repo: 'https://github.com/puppetlabs/puppetlabs-firewall.git' + ref: '0.2.1' symlinks: - "java": "#{source_dir}" - + java: "#{source_dir}" diff --git a/Gemfile b/Gemfile index be1c34c..40401e5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,31 @@ source 'https://rubygems.org' -puppetversion = ENV['PUPPET_VERSION'] - -is_ruby18 = RUBY_VERSION.start_with? '1.8' - -if is_ruby18 - gem 'rspec', "~> 3.1.0", :require => false - gem 'rake', '~> 10.5.0', :require => false +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false end -gem 'puppet', puppetversion, :require => false -gem 'puppet-lint' -gem 'puppetlabs_spec_helper', '>= 0.1.0' -gem 'rspec-puppet' + gem 'metadata-json-lint' +gem 'puppetlabs_spec_helper', '>= 1.1.1' +gem 'facter', '>= 1.7.0' +gem 'rspec-puppet' +gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git' +gem 'puppet-lint-absolute_classname-check' +gem 'puppet-lint-alias-check' +gem 'puppet-lint-empty_string-check' +gem 'puppet-lint-file_ensure-check' +gem 'puppet-lint-file_source_rights-check' +gem 'puppet-lint-leading_zero-check' +gem 'puppet-lint-spaceship_operator_without_tag-check' +gem 'puppet-lint-trailing_comma-check' +gem 'puppet-lint-unquoted_string-check' +gem 'puppet-lint-variable_contains_upcase' -group :development do - gem 'puppet-blacksmith' +# rspec must be v2 for ruby 1.8.7 +if RUBY_VERSION >= '1.8.7' and RUBY_VERSION < '1.9' + # rake >=11 does not support ruby 1.8.7 + gem 'rspec', '~> 2.0' + gem 'rake', '~> 10.0' end + diff --git a/manifests/init.pp b/manifests/init.pp index 2de6b57..98933cd 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,6 +29,8 @@ default => 'present', } + validate_absolute_path($java_home_base) + $headless_suffix = $java::bool_headless ? { true => '-headless', default => '', diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..6ae3176 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + + describe 'java' do + let(:facts) do + { :osfamily => 'Debian', + :operatingsystemmajrelease => '6', + } + end + + context 'with defaults for all parameters' do + it { should contain_class('java') } + + it { should compile.with_all_deps } + end + + let(:validation_params) do + { + #:param => 'value', + } + end + + validations = { + 'base_path' => { + :name => ['java_home_base'], + :valid => ['/usr/lib/jvm'], + :invalid => ['invalid',3,2.42,['array'],a={'ha'=>'sh'},'/etc'], + :message => 'is an invalid path', + }, + } + + validations.sort.each do |type, var| + var[:name].each do |var_name| + var[:valid].each do |valid| + context "with #{var_name} (#{type}) set to valid #{valid} (as #{valid.class})" do + let(:params) { validation_params.merge({ :"#{var_name}" => valid, }) } + it { should compile } + end + end + + var[:invalid].each do |invalid| + context "with #{var_name} (#{type}) set to invalid #{invalid} (as #{invalid.class})" do + let(:params) { validation_params.merge({ :"#{var_name}" => invalid, }) } + it 'should fail' do + expect do + should contain_class(subject) + end.to raise_error(Puppet::Error, /#{var[:message]}/) + end + end + end + end # var[:name].each + end # validations.sort.each + end # describe + #end + +