Skip to content

Commit acd34d2

Browse files
committed
Addressing srand() changes
1 parent 116998f commit acd34d2

File tree

2 files changed

+58
-24
lines changed

2 files changed

+58
-24
lines changed

spec/functions/shuffle_spec.rb

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,40 @@
2020
it { is_expected.to run.with_params([]).and_return([]) }
2121
it { is_expected.to run.with_params(['a']).and_return(['a']) }
2222
it { is_expected.to run.with_params(['one']).and_return(['one']) }
23-
it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) }
24-
it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) }
2523

26-
it { is_expected.to run.with_params('').and_return('') }
27-
it { is_expected.to run.with_params('a').and_return('a') }
28-
it { is_expected.to run.with_params('abc').and_return('bac') }
29-
it { is_expected.to run.with_params('abcd').and_return('dcba') }
24+
if Puppet::PUPPETVERSION[0].to_i < 8
25+
it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) }
26+
it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) }
3027

31-
context 'with UTF8 and double byte characters' do
32-
it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') }
33-
it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') }
34-
end
28+
it { is_expected.to run.with_params('').and_return('') }
29+
it { is_expected.to run.with_params('a').and_return('a') }
30+
it { is_expected.to run.with_params('abc').and_return('bac') }
31+
it { is_expected.to run.with_params('abcd').and_return('dcba') }
32+
33+
context 'with UTF8 and double byte characters' do
34+
it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') }
35+
it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') }
36+
end
37+
38+
context 'when using a class extending String' do
39+
it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') }
40+
end
41+
else
42+
it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['one', 'three', 'two']) }
43+
it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['one', 'three', 'two', 'four']) }
44+
45+
it { is_expected.to run.with_params('b').and_return('b') }
46+
it { is_expected.to run.with_params('abc').and_return('acb') }
47+
it { is_expected.to run.with_params('abcd').and_return('acbd') }
48+
49+
context 'with UTF8 and double byte characters' do
50+
it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ŧńş ģχţέƒůí8ґŧŧ ') }
51+
it { is_expected.to run.with_params('日本語の文字列').and_return('日列語字本文の') }
52+
end
3553

36-
context 'when using a class extending String' do
37-
it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') }
54+
context 'when using a class extending String' do
55+
it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lakfdgjsh') }
56+
end
3857
end
3958
end
4059
end

spec/functions/str2saltedsha512_spec.rb

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,32 @@
1212
# make tests deterministic
1313
before(:each) { srand(2) }
1414

15-
it {
16-
is_expected.to run.with_params('')
17-
.and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a')
18-
}
19-
it {
20-
is_expected.to run.with_params('password')
21-
.and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956')
22-
}
23-
it {
24-
is_expected.to run.with_params('verylongpassword')
25-
.and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039')
26-
}
15+
if Puppet::PUPPETVERSION[0].to_i < 8
16+
it {
17+
is_expected.to run.with_params('')
18+
.and_return('0f8a612f4eeed08e47b3875d00f33c5688f7926298f2d9b5fe19d1323f910bc78b6f7b5892596d2fabaa65e7a8d99b3768c102610cf0432c4827eee01f09451e3fae4f7a')
19+
}
20+
it {
21+
is_expected.to run.with_params('password')
22+
.and_return('0f8a612f43134376566c5707718d600effcfb17581fc9d3fa64d7f447dfda317c174ffdb498d2c5bd5c2075dab41c9d7ada5afbdc6b55354980eb5ba61802371e6b64956')
23+
}
24+
it {
25+
is_expected.to run.with_params('verylongpassword')
26+
.and_return('0f8a612f7a448537540e062daa8621f9bae326ca8ccb899e1bdb10e7c218cebfceae2530b856662565fdc4d81e986fc50cfbbc46d50436610ed9429ff5e43f2c45b5d039')
27+
}
28+
else
29+
it {
30+
is_expected.to run.with_params('')
31+
.and_return('a85c9d6f8c1eb1a625fd59e3cbca7dc7ab04ff1758d19ab99f098446e14a0a2a42e11afd1f4d6f17adfe2c772a3e6a821ee66a2564711431e14da96a3bff44593cf158ab')
32+
}
33+
it {
34+
is_expected.to run.with_params('password')
35+
.and_return('a85c9d6ff4e4dd6655ec2922ee9752550f2df4dc370e9739dd94899f62be6a42cc31fbfce3d62be35e0e8482696c931f63fb9286cf7b13d283660720c55f2a6304d06958')
36+
}
37+
it {
38+
is_expected.to run.with_params('verylongpassword')
39+
.and_return('a85c9d6fb810d0b8311c9a065c026e3179ae91fee3dbaf556f297e2fda2a8e3d8dd363977f9ef5c9b5da0cd518a5151a4e537928533291d68c9539d4d4b83da53b22a869')
40+
}
41+
end
2742
end
2843
end

0 commit comments

Comments
 (0)