-#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
-describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'size function', :if => Puppet::Util::Package.versioncmp(return_puppet_version, '6.0.0') < 0 do
describe 'success' do
- it 'single string size' do
- pp = <<-EOS
+ pp1 = <<-DOC
$a = 'discombobulate'
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
- EOS
-
- apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/size is 14/)
+ DOC
+ it 'single string size' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 14})
end
end
- it 'with empty string' do
- pp = <<-EOS
+
+ pp2 = <<-DOC
$a = ''
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
- EOS
-
- apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/size is 0/)
+ DOC
+ it 'with empty string' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 0})
end
end
- it 'with undef' do
- pp = <<-EOS
+
+ pp3 = <<-DOC
$a = undef
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
- EOS
-
- apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/size is 0/)
+ DOC
+ it 'with undef' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 0})
end
end
- it 'strings in array' do
- pp = <<-EOS
+
+ pp4 = <<-DOC
$a = ['discombobulate', 'moo']
$o = size($a)
notice(inline_template('size is <%= @o.inspect %>'))
- EOS
-
- apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/size is 2/)
+ DOC
+ it 'strings in array' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 2})
end
end
end