Skip to content

Commit 9d26274

Browse files
committed
(MODULES-9049) Add type alias for 'yes' and 'no'.
1 parent 3741204 commit 9d26274

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,10 @@ Match an IPv6 address which may contain `::` used to compress zeros as documente
670670
Match an IPv6 address in the CIDR format. It will only match if the address contains an address prefix (for example, it will match 'FF01:0:0:0:0:0:0:101/32', 'FF01::101/60', '::/0',
671671
but not 'FF01:0:0:0:0:0:0:101', 'FF01::101', '::').
672672

673+
#### `Stdlib::Yes_no`
674+
675+
Match the strings `'yes'` and `'no'`.
676+
673677
<a id="facts"></a>
674678
### Facts
675679

spec/type_aliases/yes_no_spec.rb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# coding: utf-8
2+
3+
require 'spec_helper'
4+
5+
describe 'Stdlib::Yes_no' do
6+
describe 'valid types' do
7+
[
8+
'yes',
9+
'no',
10+
].each do |value|
11+
describe value.inspect do
12+
it { is_expected.to allow_value(value) }
13+
end
14+
end
15+
end
16+
17+
describe 'invalid types' do
18+
context 'with garbage inputs' do
19+
[
20+
true,
21+
false,
22+
:keyword,
23+
nil,
24+
['yes', 'no'],
25+
{ 'foo' => 'bar' },
26+
{},
27+
'',
28+
'ネット',
29+
'55555',
30+
'0x123',
31+
'yess',
32+
'nooo',
33+
].each do |value|
34+
describe value.inspect do
35+
it { is_expected.not_to allow_value(value) }
36+
end
37+
end
38+
end
39+
end
40+
end

types/yes_no.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::Yes_no = Enum['yes', 'no']

0 commit comments

Comments
 (0)