1 require 'spec_helper_acceptance'
3 describe 'fqdn_rand_string function' do
5 include_context 'with faked facts'
6 context "when the FQDN is 'fakehost.localdomain'" do
8 fake_fact('fqdn', 'fakehost.localdomain')
13 $o = fqdn_rand_string($l)
14 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
16 it 'generates random alphanumeric strings' do
17 apply_manifest(pp1, :catch_failures => true) do |r|
18 expect(r.stdout).to match(%r{fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"})
25 $o = fqdn_rand_string($l, $c)
26 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
28 it 'generates random alphanumeric strings with custom charsets' do
29 apply_manifest(pp2, :catch_failures => true) do |r|
30 expect(r.stdout).to match(%r{fqdn_rand_string is "(7203048515|2383756694)"})
37 $o = fqdn_rand_string($l, undef, $s)
38 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
40 it 'generates random alphanumeric strings with custom seeds' do
41 apply_manifest(pp3, :catch_failures => true) do |r|
42 expect(r.stdout).to match(%r{fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"})
50 $o = fqdn_rand_string($l, $c, $s)
51 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
53 it 'generates random alphanumeric strings with custom charsets and seeds' do
54 apply_manifest(pp4, :catch_failures => true) do |r|
55 expect(r.stdout).to match(%r{fqdn_rand_string is "(3104058232|7100592312)"})
61 it 'handles improper argument counts'
62 it 'handles non-numbers for length argument'