-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Stdlib::File::Content type alias
This should describe the valid input for content. It doesn't list Undef so module authors can enforce content is set. If it's optional, Optional[Stdlib::File::Content] is easy to use.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# coding: utf-8 | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Stdlib::Filemode' do | ||
describe 'valid content' do | ||
[ | ||
'', | ||
'abc', | ||
sensitive('secret'), | ||
# TODO: test Deferred? | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.to allow_value(value) } | ||
end | ||
end | ||
|
||
context 'with garbage inputs' do | ||
[ | ||
nil, | ||
1, | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.not_to allow_value(value) } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# @summary Validate a file content attribute | ||
type Stdlib::File::Content = Variant[String, Sensitive[String], Deferred[String]] |