1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'fqdn_rand_string 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 'generates random alphanumeric strings' do
15 $o = fqdn_rand_string($l)
16 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
19 apply_manifest(pp, :catch_failures => true) do |r|
20 expect(r.stdout).to match(/fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"/)
23 it 'generates random alphanumeric strings with custom charsets' do
27 $o = fqdn_rand_string($l, $c)
28 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
31 apply_manifest(pp, :catch_failures => true) do |r|
32 expect(r.stdout).to match(/fqdn_rand_string is "(7203048515|2383756694)"/)
35 it 'generates random alphanumeric strings with custom seeds' do
39 $o = fqdn_rand_string($l, undef, $s)
40 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
43 apply_manifest(pp, :catch_failures => true) do |r|
44 expect(r.stdout).to match(/fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"/)
47 it 'generates random alphanumeric strings with custom charsets and seeds' do
52 $o = fqdn_rand_string($l, $c, $s)
53 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
56 apply_manifest(pp, :catch_failures => true) do |r|
57 expect(r.stdout).to match(/fqdn_rand_string is "(3104058232|7100592312)"/)
63 it 'handles improper argument counts'
64 it 'handles non-numbers for length argument'