diff --git a/spec/functions/stdlib_ensure_spec.rb b/spec/functions/stdlib_ensure_spec.rb index ebdcb9c..8a110b8 100644 --- a/spec/functions/stdlib_ensure_spec.rb +++ b/spec/functions/stdlib_ensure_spec.rb @@ -1,18 +1,20 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'stdlib::ensure' do context 'work with service resource' do it { is_expected.to run.with_params('present', 'service').and_return('running') } it { is_expected.to run.with_params(true, 'service').and_return('running') } it { is_expected.to run.with_params('absent', 'service').and_return('stopped') } it { is_expected.to run.with_params(false, 'service').and_return('stopped') } end ['directory', 'link', 'mounted', 'file'].each do |resource| context "work with #{resource} resource" do it { is_expected.to run.with_params('present', resource).and_return(resource) } it { is_expected.to run.with_params(true, resource).and_return(resource) } it { is_expected.to run.with_params('absent', resource).and_return('absent') } it { is_expected.to run.with_params(false, resource).and_return('absent') } end end end diff --git a/spec/type_aliases/email_spec.rb b/spec/type_aliases/email_spec.rb index 5c262c9..add96ee 100644 --- a/spec/type_aliases/email_spec.rb +++ b/spec/type_aliases/email_spec.rb @@ -1,70 +1,72 @@ +# frozen_string_literal: true + require 'spec_helper' # Test cases are a combination of the test cases used in MediaWiki[1] and a # Reference found on line[2]. Some of the test cases in the later list have # been dropped as the regex used in the HTML5 specification[3] (and in this type) # allows for wilful violation of the RFC's # # [1]https://github.com/wikimedia/mediawiki/blob/master/tests/phpunit/integration \ # /includes/SanitizerValidateEmailTest.php # [2]https://gist.github.com/cjaoude/fd9910626629b53c4d25 # [3]https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address describe 'Stdlib::Email' do describe 'valid handling' do ['email@example.com', 'EMAIL@example.com', 'email@EXAMPLE.com', 'email@192.0.2.1', '_______@example.com', 'firstname.lastname@example.com', 'firstname+lastname@example.com', 'firstname-lastname@example.com', '1234567890@example.com', 'email@subdomain.example.com', 'email@example-one.com', 'email@example.name', 'email@example.museum', 'email@example.co.jp', 'email@example', 'user@example.1234', 'user@a'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end end end describe 'invalid handling' do ['plainaddress', '#@%^%#$@#$@#.com', '@example.com', ' email@example.com', 'email@example.com ', "email@example.com\t", 'user email@example.com', 'useremail@example com', 'user,email@example.com', 'useremail@example,com', 'useremail@.', 'useremail@.example.org', 'useremail@a......', 'useràexample.com', 'Joe Smith ', 'email.example.com', 'email@example@example.com', 'あいうえお@example.com', 'email@example.com (Joe Smith)', 'email@-example.com', 'email@example..com', 'random stuff multiline valid@email.com more random stuff $^*!', '”(),:;<>[\]@example.com', 'just”not”right@example.com', 'this\ is"really"not\allowed@example.com'].each do |value| describe value.inspect do it { is_expected.not_to allow_value(value) } end end end end