1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'fqdn_rotate function' do
6 include_context "with faked facts"
7 context "when the FQDN is 'fakehost.localdomain'" do
9 fake_fact("fqdn", "fakehost.localdomain")
12 it 'rotates arrays' do
14 $a = ['a','b','c','d']
16 notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
19 apply_manifest(pp, :catch_failures => true) do |r|
20 expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/)
23 it 'rotates arrays with custom seeds' do
25 $a = ['a','b','c','d']
27 $o = fqdn_rotate($a, $s)
28 notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
31 apply_manifest(pp, :catch_failures => true) do |r|
32 expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
35 it 'rotates strings' do
39 notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
42 apply_manifest(pp, :catch_failures => true) do |r|
43 expect(r.stdout).to match(/fqdn_rotate is "dabc"/)
46 it 'rotates strings with custom seeds' do
50 $o = fqdn_rotate($a, $s)
51 notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
54 apply_manifest(pp, :catch_failures => true) do |r|
55 expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
61 it 'handles improper argument counts'
62 it 'handles invalid arguments'