From 9104c3dc8eaaee1628a013dc3c07e7070922935c Mon Sep 17 00:00:00 2001 From: Douglas F Shearer Date: Fri, 6 Sep 2013 13:14:28 +0100 Subject: [PATCH 1/2] Add ability to specify which version of the gem to install. --- attributes/default.rb | 1 + recipes/gem.rb | 4 +++- spec/gem_spec.rb | 13 +++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) 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..6bba1e7 100644 --- a/recipes/gem.rb +++ b/recipes/gem.rb @@ -1 +1,3 @@ -gem_package "remote_syslog" +gem_package "remote_syslog" do + version node.remote_syslog.version +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 From 000a30b134557e0afbd7deacb913e1f8d33bd623 Mon Sep 17 00:00:00 2001 From: Douglas F Shearer Date: Wed, 24 Jun 2015 21:47:06 +0100 Subject: [PATCH 2/2] Auto-upgrade remote_syslog gem. --- recipes/gem.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/gem.rb b/recipes/gem.rb index 6bba1e7..8f1cbb9 100644 --- a/recipes/gem.rb +++ b/recipes/gem.rb @@ -1,3 +1,4 @@ gem_package "remote_syslog" do version node.remote_syslog.version + action :upgrade end