source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/functions/defined_with_params_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 7 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1require 'spec_helper'
2
3describe 'defined_with_params' do
4 describe 'when no resource is specified' do
5 it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
6 end
7 describe 'when compared against a resource with no attributes' do
8 let :pre_condition do
9 'user { "dan": }'
10 end
11 it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
12 it { is_expected.to run.with_params('User[bob]', {}).and_return(false) }
13 it { is_expected.to run.with_params('User[dan]', {'foo' => 'bar'}).and_return(false) }
14 end
15
16 describe 'when compared against a resource with attributes' do
17 let :pre_condition do
18 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}'
19 end
20 it { is_expected.to run.with_params('User[dan]', {}).and_return(true) }
21 it { is_expected.to run.with_params('User[dan]', '').and_return(true) }
22 it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present'}).and_return(true) }
23 it { is_expected.to run.with_params('User[dan]', {'ensure' => 'present', 'managehome' => false}).and_return(true) }
24 it { is_expected.to run.with_params('User[dan]', {'ensure' => 'absent', 'managehome' => false}).and_return(false) }
25 end
26
27 describe 'when passing undef values' do
28 let :pre_condition do
29 'file { "/tmp/a": ensure => present }'
30 end
31
32 it { is_expected.to run.with_params('File[/tmp/a]', {}).and_return(true) }
33 it { is_expected.to run.with_params('File[/tmp/a]', { 'ensure' => 'present', 'owner' => :undef }).and_return(true) }
34 end
35end
Note: See TracBrowser for help on using the repository browser.