We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9f01903 commit a7c9790Copy full SHA for a7c9790
spec/type_aliases/yes_no_spec.rb
@@ -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
19
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
38
39
+ it { is_expected.not_to allow_value(value) }
40
41
42
43
44
+end
types/yes_no.pp
@@ -0,0 +1 @@
+type Stdlib::Yes_no = Pattern[/\A(?i:(yes|no))\z/]
0 commit comments