module-puppetlabs-apt/spec/defines/force_spec.rb
Matthaus Litteken d522877cdd (#12094) Replace chained .with_* with a hash
The hash passing to the with method is cleaner and closer to puppet code, so
all of the with_$param have been replaced with with($hash). This also
includes two minor whitspace changes to unstable.pp and source.pp.
This also replaces the ternary switch on param_set with a hash merge,
which is cleaner and will support more use cases.
2012-02-08 09:24:43 -08:00

41 lines
994 B
Ruby

require 'spec_helper'
describe 'apt::force', :type => :define do
let :title do
'my_package'
end
let :default_params do
{
:release => 'testing',
:version => false
}
end
[{},
{
:release => 'stable',
:version => '1'
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
let :param_hash do
default_params.merge(param_set)
end
let :params do
param_set
end
let :unless_query do
base_command = "/usr/bin/dpkg -s #{title} | grep -q "
base_command + (params[:version] ? "'Version: #{params[:version]}'" : "'Status: install'")
end
let :exec_title do
base_exec = "/usr/bin/aptitude -y -t #{param_hash[:release]} install #{title}"
base_exec + (params[:version] ? "=#{params[:version]}" : "")
end
it { should contain_exec(exec_title).with_unless(unless_query) }
end
end
end