summaryrefslogtreecommitdiff
path: root/spec/functions/fqdn_rotate_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/functions/fqdn_rotate_spec.rb')
-rwxr-xr-xspec/functions/fqdn_rotate_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/functions/fqdn_rotate_spec.rb b/spec/functions/fqdn_rotate_spec.rb
index b2dc1f5..673a8a3 100755
--- a/spec/functions/fqdn_rotate_spec.rb
+++ b/spec/functions/fqdn_rotate_spec.rb
@@ -30,4 +30,31 @@ describe "the fqdn_rotate function" do
val2 = scope.function_fqdn_rotate(["abcdefghijklmnopqrstuvwxyz01234567890987654321"])
expect(val1).not_to eql(val2)
end
+
+ it "should accept objects which extend String" do
+ class AlsoString < String
+ end
+
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
+ value = AlsoString.new("asdf")
+ result = scope.function_fqdn_rotate([value])
+ result.size.should(eq(4))
+ end
+
+ it "should use the Puppet::Util.deterministic_rand function if available" do
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
+ if Puppet::Util.respond_to?(:deterministic_rand)
+ Puppet::Util.expects(:deterministic_rand).with(113646079810780526294648115052177588845,4)
+ end
+ scope.function_fqdn_rotate(["asdf"])
+ end
+
+ it "should not leave the global seed in a deterministic state" do
+ scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
+ scope.function_fqdn_rotate(["asdf"])
+ rand1 = rand()
+ scope.function_fqdn_rotate(["asdf"])
+ rand2 = rand()
+ expect(rand1).not_to eql(rand2)
+ end
end