puppetlabs-stdlib/spec/acceptance/union_spec.rb
Jetroid 1d9189d860 (MODULE-2456) Modify union to accept more than two arrays
Add spec tests to test the new functionality:
 *Case for 3 arrays.
 *Case for 4 arrays.
Modify README to note new functionality.

This is for issue MODULE-2456, follow the precedent of MODULE-444.

This change allows union to be much more useful, unioning many arrays
in one line rather than in n lines. Additionally, as this is only added
functionality, and does not affect the 2 array case that all modules
currently using array are using, it should not affect any existing
modules utilizing union.

This is now useful, for example, for merging many arrays of resources
(eg: packages.) to generate just one list with no duplicates, to avoid
duplicate resource declarations.
2015-08-24 14:24:10 +01:00

25 lines
702 B
Ruby
Executable file

#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
it 'unions arrays' do
pp = <<-EOS
$a = ["the","public"]
$b = ["art"]
$c = ["galleries"]
# Anagram: Large picture halls, I bet
$o = union($a,$b,$c)
notice(inline_template('union is <%= @o.inspect %>'))
EOS
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/union is \["the", "public", "art", "galleries"\]/)
end
end
end
describe 'failure' do
it 'handles no arguments'
it 'handles non arrays'
end
end