/
nil_class.fy
62 lines (51 loc) · 1.7 KB
/
nil_class.fy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
FancySpec describe: NilClass with: {
it: "should be false for calling and: with any value" for: 'and: when: {
nil and: true . should == nil
nil and: 'foo . should == nil
nil and: nil . should == nil
false and: true . should == false
false and: 'foo . should == false
false and: nil . should == false
}
it: "should be nil/false for calling && with any value" for: '&& when: {
(nil && true) should == nil
(nil && 'foo) should == nil
(nil && nil) should == nil
(false && true) should == false
(false && 'foo) should == false
(false && nil) should == false
}
it: "should be true for calling or: with any non-nil value" for: 'or: when: {
nil or: true . should == true
nil or: 'foo . should == 'foo
}
it: "should be nil/false for calling or: with a nil/false value" for: 'or: when: {
nil or: nil . should == nil
nil or: false . should == false
}
it: "should be true for calling || with any non-nil value" for: '|| when: {
(nil || true) should == true
(nil || 'foo) should == 'foo
}
it: "should be nil for calling || with a nil value" for: '|| when: {
(nil || nil) should == nil
}
it: "should NOT call the block" for: 'if_true: when: {
nil if_true: { 'then } . should == nil
}
it: "should not call the block" for: 'if_false: when: {
nil if_false: { 'false } . should == nil
}
it: "should be nil" for: 'nil? when: {
nil nil? should == true
}
it: "should be false" for: 'false? when: {
nil false? should == false
}
it: "should NOT be true" for: 'true? when: {
nil true? should == false
}
it: "should call the block if nil" for: 'if_nil: when: {
nil if_nil: { 'is_nil } . should == 'is_nil
}
}