2015-09-14 19:26:25 +02:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
|
|
|
require 'spec_helper_acceptance'
|
|
|
|
|
2015-09-21 23:12:25 +02:00
|
|
|
if get_puppet_version =~ /^4/
|
|
|
|
describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
|
|
|
it 'should match a string' do
|
|
|
|
pp = <<-EOS
|
|
|
|
if 'hello world'.is_a(String) {
|
|
|
|
notify { 'output correct': }
|
|
|
|
}
|
|
|
|
EOS
|
2015-09-14 19:26:25 +02:00
|
|
|
|
2015-09-21 23:12:25 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).to match(/Notice: output correct/)
|
|
|
|
end
|
2015-09-14 19:26:25 +02:00
|
|
|
end
|
|
|
|
|
2015-09-21 23:12:25 +02:00
|
|
|
it 'should not match a integer as string' do
|
|
|
|
pp = <<-EOS
|
|
|
|
if 5.is_a(String) {
|
|
|
|
notify { 'output wrong': }
|
|
|
|
}
|
|
|
|
EOS
|
2015-09-14 19:26:25 +02:00
|
|
|
|
2015-09-21 23:12:25 +02:00
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).not_to match(/Notice: output wrong/)
|
|
|
|
end
|
2015-09-14 19:26:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|