Skip to content

Commit f34f284

Browse files
authored
Merge pull request #1017 from ghoneycutt/9049_yes_no
(MODULES-9049) Add type alias for 'yes' and 'no'.
2 parents 8e42cf9 + a7c9790 commit f34f284

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

spec/type_aliases/yes_no_spec.rb

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
'YES',
11+
'Yes',
12+
'NO',
13+
'No',
14+
].each do |value|
15+
describe value.inspect do
16+
it { is_expected.to allow_value(value) }
17+
end
18+
end
19+
end
20+
21+
describe 'invalid types' do
22+
context 'with garbage inputs' do
23+
[
24+
true,
25+
false,
26+
:keyword,
27+
nil,
28+
['yes', 'no'],
29+
{ 'foo' => 'bar' },
30+
{},
31+
'',
32+
'ネット',
33+
'55555',
34+
'0x123',
35+
'yess',
36+
'nooo',
37+
].each do |value|
38+
describe value.inspect do
39+
it { is_expected.not_to allow_value(value) }
40+
end
41+
end
42+
end
43+
end
44+
end

types/yes_no.pp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::Yes_no = Pattern[/\A(?i:(yes|no))\z/]

0 commit comments

Comments
 (0)