diff --git a/attributes/default.rb b/attributes/default.rb index b05ba05..51abc10 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,3 +1,4 @@ +default.remote_syslog.version = nil # Latest version is installed if nil. default.remote_syslog.init_style = "init" default.remote_syslog.conf.files = ["/var/log/*.*"] default.remote_syslog.destination.host = "logs.papertrailapp.com" diff --git a/recipes/gem.rb b/recipes/gem.rb index 8ac84e7..8f1cbb9 100644 --- a/recipes/gem.rb +++ b/recipes/gem.rb @@ -1 +1,4 @@ -gem_package "remote_syslog" +gem_package "remote_syslog" do + version node.remote_syslog.version + action :upgrade +end diff --git a/spec/gem_spec.rb b/spec/gem_spec.rb index b12dc92..c80503c 100644 --- a/spec/gem_spec.rb +++ b/spec/gem_spec.rb @@ -1,9 +1,18 @@ require 'chefspec' describe 'remote_syslog::gem ' do - let (:chef_run) { ChefSpec::ChefRunner.new.converge 'remote_syslog::gem' } + let (:chef_run) { ChefSpec::ChefRunner.new } + + it 'should install the gem' do + chef_run.converge 'remote_syslog::gem' - it 'should do something' do chef_run.should install_gem_package 'remote_syslog' end + + it 'should install the gem with the specified version' do + chef_run.node.set['remote_syslog']['version'] = '1.6.7.2' + chef_run.converge 'remote_syslog::gem' + + chef_run.should install_gem_package_at_version 'remote_syslog', '1.6.7.2' + end end