summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJeff McCune <jeff@puppetlabs.com>2013-01-09 17:52:41 -0800
committerJeff McCune <jeff@puppetlabs.com>2013-01-09 17:52:41 -0800
commit3118e642dc9ec460b5c2e5220bed3b54c977f27c (patch)
tree85d283d806ded7d21a02c0fda4ce8df7ebc9906f /spec
parentd674190d8e160b74250c514775003569b36d9984 (diff)
parent20e0e0709021b7ba4a819f1324526d98bcb5dcc3 (diff)
Merge branch 'offlinehacker-feature/master/getparam_function'
* offlinehacker-feature/master/getparam_function: Add getparam function to get defined resource parameters
Diffstat (limited to 'spec')
-rw-r--r--spec/functions/getparam_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/functions/getparam_spec.rb b/spec/functions/getparam_spec.rb
new file mode 100644
index 0000000..d9c50a6
--- /dev/null
+++ b/spec/functions/getparam_spec.rb
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper'
+
+require 'rspec-puppet'
+describe 'getparam' do
+ describe 'when a resource is not specified' do
+ it do
+ should run.with_params().and_raise_error(ArgumentError)
+ should run.with_params('User[dan]').and_raise_error(ArgumentError)
+ should run.with_params('User[dan]', {}).and_raise_error(ArgumentError)
+ should run.with_params('User[dan]', '').and_return('')
+ end
+ end
+ describe 'when compared against a resource with no params' do
+ let :pre_condition do
+ 'user { "dan": }'
+ end
+ it do
+ should run.with_params('User[dan]', 'shell').and_return('')
+ end
+ end
+
+ describe 'when compared against a resource with params' do
+ let :pre_condition do
+ 'user { "dan": ensure => present, shell => "/bin/sh", managehome => false}'
+ end
+ it do
+ should run.with_params('User[dan]', 'shell').and_return('/bin/sh')
+ should run.with_params('User[dan]', '').and_return('')
+ should run.with_params('User[dan]', 'ensure').and_return('present')
+ should run.with_params('User[dan]', 'managehome').and_return(false)
+ end
+ end
+end