|
| 1 | +require 'spec_helper_acceptance' |
| 2 | + |
| 3 | +describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do |
| 4 | + describe 'success' do |
| 5 | + it 'rejects array of values' do |
| 6 | + pp = <<-EOS |
| 7 | + $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa') |
| 8 | + notice(inline_template('reject is <%= @o.inspect %>')) |
| 9 | + EOS |
| 10 | + |
| 11 | + apply_manifest(pp, :catch_failures => true) do |r| |
| 12 | + expect(r.stdout).to match(/reject is \["bbb", "ccc"\]/) |
| 13 | + end |
| 14 | + end |
| 15 | + it 'rejects with empty array' do |
| 16 | + pp = <<-EOS |
| 17 | + $o = reject([],'aaa') |
| 18 | + notice(inline_template('reject is <%= @o.inspect %>')) |
| 19 | + EOS |
| 20 | + |
| 21 | + apply_manifest(pp, :catch_failures => true) do |r| |
| 22 | + expect(r.stdout).to match(/reject is \[\]/) |
| 23 | + end |
| 24 | + end |
| 25 | + it 'rejects array of values with undef' do |
| 26 | + pp = <<-EOS |
| 27 | + $o = reject(['aaa','bbb','ccc','aaaddd'], undef) |
| 28 | + notice(inline_template('reject is <%= @o.inspect %>')) |
| 29 | + EOS |
| 30 | + |
| 31 | + apply_manifest(pp, :catch_failures => true) do |r| |
| 32 | + expect(r.stdout).to match(/reject is \["aaa", "bbb", "ccc", "aaaddd"\]/) |
| 33 | + end |
| 34 | + end |
| 35 | + end |
| 36 | + describe 'failure' do |
| 37 | + it 'fails with no arguments' |
| 38 | + it 'fails when first argument is not array' |
| 39 | + it 'fails when second argument is not string' |
| 40 | + end |
| 41 | +end |
0 commit comments