File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
1
+ type Stdlib::Yes_no = Pattern[/\A(?i:(yes|no))\z/]
You can’t perform that action at this time.
0 commit comments