summaryrefslogtreecommitdiff
path: root/code/environments/production/modules/stdlib/spec/functions/getparam_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'code/environments/production/modules/stdlib/spec/functions/getparam_spec.rb')
-rw-r--r--code/environments/production/modules/stdlib/spec/functions/getparam_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/code/environments/production/modules/stdlib/spec/functions/getparam_spec.rb b/code/environments/production/modules/stdlib/spec/functions/getparam_spec.rb
new file mode 100644
index 0000000..3a3cc27
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/functions/getparam_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe 'getparam' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a reference}) }
+ it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+ it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+ it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+ it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
+
+ describe 'when compared against a user resource with no params' do
+ let(:pre_condition) { 'user { "one": }' }
+
+ it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') }
+ it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
+ it { is_expected.to run.with_params('User[one]', 'shell').and_return('') }
+ end
+
+ describe 'when compared against a user resource with params' do
+ let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' }
+
+ it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') }
+ it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
+ it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') }
+ it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) }
+ end
+
+ describe 'when compared against a user resource with UTF8 and double byte params' do
+ let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' }
+
+ it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') }
+ it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') }
+ end
+end