Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / validate_email_address_spec.rb
1 require 'spec_helper'
2
3 describe 'validate_email_address' do
4   describe 'signature validation' do
5     it { is_expected.not_to eq(nil) }
6     it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
7   end
8
9   describe 'valid inputs' do
10     it { is_expected.to run.with_params('bob@gmail.com') }
11     it { is_expected.to run.with_params('alice+puppetlabs.com@gmail.com') }
12   end
13
14   describe 'invalid inputs' do
15     it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
16     it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a string}) }
17     it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
18     it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a valid email}) }
19     it { is_expected.to run.with_params('bob@gmail.com', {}).and_raise_error(Puppet::ParseError, %r{is not a string}) }
20     it { is_expected.to run.with_params('bob@gmail.com', true).and_raise_error(Puppet::ParseError, %r{is not a string}) }
21     it { is_expected.to run.with_params('bob@gmail.com', 'one').and_raise_error(Puppet::ParseError, %r{is not a valid email}) }
22   end
23 end