Skip to content

Commit cebb9f3

Browse files
committed
Merge pull request puppetlabs#528 from mhaskel/is_a_fixes
Update is_a acceptance tests to only run on puppet4
2 parents 97bd656 + b20239e commit cebb9f3

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

spec/acceptance/is_a_spec.rb

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
#! /usr/bin/env ruby -S rspec
22
require 'spec_helper_acceptance'
33

4-
describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5-
it 'should match a string' do
6-
pp = <<-EOS
7-
if 'hello world'.is_a(String) {
8-
notify { 'output correct': }
9-
}
10-
EOS
4+
if get_puppet_version =~ /^4/
5+
describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
6+
it 'should match a string' do
7+
pp = <<-EOS
8+
if 'hello world'.is_a(String) {
9+
notify { 'output correct': }
10+
}
11+
EOS
1112

12-
apply_manifest(pp, :catch_failures => true) do |r|
13-
expect(r.stdout).to match(/Notice: output correct/)
13+
apply_manifest(pp, :catch_failures => true) do |r|
14+
expect(r.stdout).to match(/Notice: output correct/)
15+
end
1416
end
15-
end
1617

17-
it 'should not match a integer as string' do
18-
pp = <<-EOS
19-
if 5.is_a(String) {
20-
notify { 'output wrong': }
21-
}
22-
EOS
18+
it 'should not match a integer as string' do
19+
pp = <<-EOS
20+
if 5.is_a(String) {
21+
notify { 'output wrong': }
22+
}
23+
EOS
2324

24-
apply_manifest(pp, :catch_failures => true) do |r|
25-
expect(r.stdout).not_to match(/Notice: output wrong/)
25+
apply_manifest(pp, :catch_failures => true) do |r|
26+
expect(r.stdout).not_to match(/Notice: output wrong/)
27+
end
2628
end
2729
end
2830
end

spec/spec_helper_acceptance.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ def is_future_parser_enabled?
3333
return false
3434
end
3535

36+
def get_puppet_version
37+
(on default, puppet('--version')).output.chomp
38+
end
39+
3640
RSpec.shared_context "with faked facts" do
3741
let(:facts_d) do
38-
puppet_version = (on default, puppet('--version')).output.chomp
42+
puppet_version = get_puppet_version
3943
if fact('osfamily') =~ /windows/i
4044
if fact('kernelmajversion').to_f < 6.0
4145
'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'

0 commit comments

Comments
 (0)