Skip to content

Commit 4fd49ea

Browse files
committed
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.
1 parent 02b42fd commit 4fd49ea

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# coding: utf-8
2+
# frozen_string_literal: true
3+
4+
require 'spec_helper'
5+
6+
describe 'Stdlib::File::Content' do
7+
describe 'valid content' do
8+
[
9+
'',
10+
'abc',
11+
sensitive('secret'),
12+
# TODO: test Deferred and Binary?
13+
].each do |value|
14+
describe value.inspect do
15+
it { is_expected.to allow_value(value) }
16+
end
17+
end
18+
19+
context 'with garbage inputs' do
20+
[
21+
nil,
22+
1,
23+
].each do |value|
24+
describe value.inspect do
25+
it { is_expected.not_to allow_value(value) }
26+
end
27+
end
28+
end
29+
end
30+
end

types/file/content.pp

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# @summary Validate a file content attribute
2+
type Stdlib::File::Content = Variant[String, Sensitive[String], Deferred[String], Binary]

0 commit comments

Comments
 (0)