fear 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -60
  3. data/.travis.yml +8 -4
  4. data/CHANGELOG.md +7 -1
  5. data/Gemfile +5 -3
  6. data/Gemfile.lock +18 -20
  7. data/README.md +28 -14
  8. data/Rakefile +61 -60
  9. data/examples/pattern_extracting.rb +8 -6
  10. data/examples/pattern_matching_binary_tree_set.rb +4 -2
  11. data/examples/pattern_matching_number_in_words.rb +46 -42
  12. data/fear.gemspec +29 -27
  13. data/lib/fear.rb +44 -37
  14. data/lib/fear/await.rb +33 -0
  15. data/lib/fear/awaitable.rb +28 -0
  16. data/lib/fear/either.rb +2 -0
  17. data/lib/fear/either_api.rb +2 -0
  18. data/lib/fear/either_pattern_match.rb +2 -0
  19. data/lib/fear/empty_partial_function.rb +3 -1
  20. data/lib/fear/extractor.rb +30 -28
  21. data/lib/fear/extractor/anonymous_array_splat_matcher.rb +2 -0
  22. data/lib/fear/extractor/any_matcher.rb +2 -0
  23. data/lib/fear/extractor/array_head_matcher.rb +2 -0
  24. data/lib/fear/extractor/array_matcher.rb +2 -0
  25. data/lib/fear/extractor/array_splat_matcher.rb +2 -0
  26. data/lib/fear/extractor/empty_list_matcher.rb +2 -0
  27. data/lib/fear/extractor/extractor_matcher.rb +5 -3
  28. data/lib/fear/extractor/grammar.rb +5 -3
  29. data/lib/fear/extractor/identifier_matcher.rb +2 -0
  30. data/lib/fear/extractor/matcher.rb +5 -3
  31. data/lib/fear/extractor/matcher/and.rb +3 -1
  32. data/lib/fear/extractor/named_array_splat_matcher.rb +2 -0
  33. data/lib/fear/extractor/pattern.rb +7 -5
  34. data/lib/fear/extractor/typed_identifier_matcher.rb +2 -0
  35. data/lib/fear/extractor/value_matcher.rb +2 -0
  36. data/lib/fear/extractor_api.rb +2 -0
  37. data/lib/fear/failure.rb +2 -0
  38. data/lib/fear/failure_pattern_match.rb +2 -0
  39. data/lib/fear/for.rb +4 -2
  40. data/lib/fear/for_api.rb +3 -1
  41. data/lib/fear/future.rb +141 -64
  42. data/lib/fear/future_api.rb +2 -0
  43. data/lib/fear/left.rb +3 -1
  44. data/lib/fear/left_pattern_match.rb +2 -0
  45. data/lib/fear/none.rb +4 -2
  46. data/lib/fear/none_pattern_match.rb +2 -0
  47. data/lib/fear/option.rb +3 -1
  48. data/lib/fear/option_api.rb +2 -0
  49. data/lib/fear/option_pattern_match.rb +2 -0
  50. data/lib/fear/partial_function.rb +10 -8
  51. data/lib/fear/partial_function/and_then.rb +4 -2
  52. data/lib/fear/partial_function/any.rb +2 -0
  53. data/lib/fear/partial_function/combined.rb +3 -1
  54. data/lib/fear/partial_function/empty.rb +2 -0
  55. data/lib/fear/partial_function/guard.rb +7 -5
  56. data/lib/fear/partial_function/guard/and.rb +2 -0
  57. data/lib/fear/partial_function/guard/and3.rb +2 -0
  58. data/lib/fear/partial_function/guard/or.rb +2 -0
  59. data/lib/fear/partial_function/lifted.rb +2 -0
  60. data/lib/fear/partial_function/or_else.rb +3 -1
  61. data/lib/fear/partial_function_class.rb +3 -1
  62. data/lib/fear/pattern_match.rb +3 -1
  63. data/lib/fear/pattern_matching_api.rb +3 -1
  64. data/lib/fear/promise.rb +11 -3
  65. data/lib/fear/right.rb +3 -1
  66. data/lib/fear/right_biased.rb +4 -2
  67. data/lib/fear/right_pattern_match.rb +2 -0
  68. data/lib/fear/some.rb +2 -0
  69. data/lib/fear/some_pattern_match.rb +2 -0
  70. data/lib/fear/struct.rb +235 -0
  71. data/lib/fear/success.rb +2 -0
  72. data/lib/fear/success_pattern_match.rb +2 -0
  73. data/lib/fear/try.rb +2 -0
  74. data/lib/fear/try_api.rb +2 -0
  75. data/lib/fear/try_pattern_match.rb +2 -0
  76. data/lib/fear/unit.rb +6 -2
  77. data/lib/fear/utils.rb +4 -2
  78. data/lib/fear/version.rb +4 -1
  79. data/spec/fear/done_spec.rb +7 -5
  80. data/spec/fear/either/mixin_spec.rb +4 -2
  81. data/spec/fear/either_pattern_match_spec.rb +10 -8
  82. data/spec/fear/extractor/array_matcher_spec.rb +65 -63
  83. data/spec/fear/extractor/extractor_matcher_spec.rb +64 -62
  84. data/spec/fear/extractor/grammar_array_spec.rb +5 -3
  85. data/spec/fear/extractor/identified_matcher_spec.rb +18 -16
  86. data/spec/fear/extractor/identifier_matcher_spec.rb +26 -24
  87. data/spec/fear/extractor/pattern_spec.rb +17 -15
  88. data/spec/fear/extractor/typed_identifier_matcher_spec.rb +23 -21
  89. data/spec/fear/extractor/value_matcher_number_spec.rb +29 -27
  90. data/spec/fear/extractor/value_matcher_string_spec.rb +27 -25
  91. data/spec/fear/extractor/value_matcher_symbol_spec.rb +24 -22
  92. data/spec/fear/extractor_api_spec.rb +70 -68
  93. data/spec/fear/extractor_spec.rb +23 -21
  94. data/spec/fear/failure_spec.rb +59 -57
  95. data/spec/fear/for_spec.rb +19 -17
  96. data/spec/fear/future_spec.rb +456 -240
  97. data/spec/fear/guard_spec.rb +26 -24
  98. data/spec/fear/left_spec.rb +60 -58
  99. data/spec/fear/none_spec.rb +36 -34
  100. data/spec/fear/option/mixin_spec.rb +9 -7
  101. data/spec/fear/option_pattern_match_spec.rb +10 -8
  102. data/spec/fear/partial_function/empty_spec.rb +12 -10
  103. data/spec/fear/partial_function_and_then_spec.rb +39 -37
  104. data/spec/fear/partial_function_composition_spec.rb +46 -44
  105. data/spec/fear/partial_function_or_else_spec.rb +92 -90
  106. data/spec/fear/partial_function_spec.rb +46 -44
  107. data/spec/fear/pattern_match_spec.rb +31 -29
  108. data/spec/fear/promise_spec.rb +19 -17
  109. data/spec/fear/right_biased/left.rb +28 -26
  110. data/spec/fear/right_biased/right.rb +51 -49
  111. data/spec/fear/right_spec.rb +58 -56
  112. data/spec/fear/some_spec.rb +30 -28
  113. data/spec/fear/success_spec.rb +50 -48
  114. data/spec/fear/try/mixin_spec.rb +5 -3
  115. data/spec/fear/try_pattern_match_spec.rb +10 -8
  116. data/spec/fear/utils_spec.rb +16 -14
  117. data/spec/spec_helper.rb +7 -5
  118. data/spec/struct_spec.rb +226 -0
  119. metadata +18 -13
@@ -1,85 +1,87 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples Fear::RightBiased::Left do
2
- describe '#include?' do
4
+ describe "#include?" do
3
5
  subject { left }
4
- it { is_expected.not_to include('value') }
6
+ it { is_expected.not_to include("value") }
5
7
  end
6
8
 
7
- describe '#get_or_else' do
8
- context 'with block' do
9
- subject { left.get_or_else { 'default' } }
9
+ describe "#get_or_else" do
10
+ context "with block" do
11
+ subject { left.get_or_else { "default" } }
10
12
 
11
- it 'returns default value' do
12
- is_expected.to eq('default')
13
+ it "returns default value" do
14
+ is_expected.to eq("default")
13
15
  end
14
16
  end
15
17
 
16
- context 'with default argument' do
17
- subject { left.get_or_else('default') }
18
+ context "with default argument" do
19
+ subject { left.get_or_else("default") }
18
20
 
19
- it 'returns default value' do
20
- is_expected.to eq('default')
21
+ it "returns default value" do
22
+ is_expected.to eq("default")
21
23
  end
22
24
  end
23
25
 
24
- context 'with false argument' do
26
+ context "with false argument" do
25
27
  subject { left.get_or_else(false) }
26
28
 
27
- it 'returns default value' do
29
+ it "returns default value" do
28
30
  is_expected.to eq(false)
29
31
  end
30
32
  end
31
33
 
32
- context 'with nil argument' do
34
+ context "with nil argument" do
33
35
  subject { left.get_or_else(nil) }
34
36
 
35
- it 'returns default value' do
37
+ it "returns default value" do
36
38
  is_expected.to eq(nil)
37
39
  end
38
40
  end
39
41
  end
40
42
 
41
- describe '#each' do
43
+ describe "#each" do
42
44
  subject do
43
45
  proc do |block|
44
46
  expect(left.each(&block)).to eq(left)
45
47
  end
46
48
  end
47
49
 
48
- it 'does not call the block' do
50
+ it "does not call the block" do
49
51
  is_expected.not_to yield_control
50
52
  end
51
53
  end
52
54
 
53
- describe '#map' do
55
+ describe "#map" do
54
56
  subject { left.map(&:length) }
55
57
 
56
- it 'returns self' do
58
+ it "returns self" do
57
59
  is_expected.to eq(left)
58
60
  end
59
61
  end
60
62
 
61
- describe '#flat_map' do
63
+ describe "#flat_map" do
62
64
  subject { left.flat_map(&:length) }
63
65
 
64
- it 'returns self' do
66
+ it "returns self" do
65
67
  is_expected.to eq(left)
66
68
  end
67
69
  end
68
70
 
69
- describe '#to_option' do
71
+ describe "#to_option" do
70
72
  subject { left.to_option }
71
73
  it { is_expected.to eq(Fear::None) }
72
74
  end
73
75
 
74
- describe '#any?' do
75
- subject { left.any? { |v| v == 'value' } }
76
+ describe "#any?" do
77
+ subject { left.any? { |v| v == "value" } }
76
78
  it { is_expected.to eq(false) }
77
79
  end
78
80
 
79
- describe '#===' do
81
+ describe "#===" do
80
82
  subject { match === left }
81
83
 
82
- context 'the same object' do
84
+ context "the same object" do
83
85
  let(:match) { left }
84
86
  it { is_expected.to eq(true) }
85
87
  end
@@ -1,141 +1,143 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples Fear::RightBiased::Right do
2
- describe '#include?' do
3
- context 'contains value' do
4
- subject { right.include?('value') }
4
+ describe "#include?" do
5
+ context "contains value" do
6
+ subject { right.include?("value") }
5
7
  it { is_expected.to eq(true) }
6
8
  end
7
9
 
8
- context 'does not contain value' do
9
- subject { right.include?('another value') }
10
+ context "does not contain value" do
11
+ subject { right.include?("another value") }
10
12
  it { is_expected.to eq(false) }
11
13
  end
12
14
  end
13
15
 
14
- describe '#get_or_else' do
15
- context 'with block' do
16
- subject { right.get_or_else { 'default' } }
16
+ describe "#get_or_else" do
17
+ context "with block" do
18
+ subject { right.get_or_else { "default" } }
17
19
 
18
- it 'returns value' do
19
- is_expected.to eq('value')
20
+ it "returns value" do
21
+ is_expected.to eq("value")
20
22
  end
21
23
  end
22
24
 
23
- context 'with default argument' do
24
- subject { right.get_or_else('default') }
25
+ context "with default argument" do
26
+ subject { right.get_or_else("default") }
25
27
 
26
- it 'returns value' do
27
- is_expected.to eq('value')
28
+ it "returns value" do
29
+ is_expected.to eq("value")
28
30
  end
29
31
  end
30
32
 
31
- context 'with false argument' do
33
+ context "with false argument" do
32
34
  subject { right.get_or_else(false) }
33
35
 
34
- it 'returns value' do
35
- is_expected.to eq('value')
36
+ it "returns value" do
37
+ is_expected.to eq("value")
36
38
  end
37
39
  end
38
40
 
39
- context 'with nil argument' do
41
+ context "with nil argument" do
40
42
  subject { right.get_or_else(nil) }
41
43
 
42
- it 'returns value' do
43
- is_expected.to eq('value')
44
+ it "returns value" do
45
+ is_expected.to eq("value")
44
46
  end
45
47
  end
46
48
  end
47
49
 
48
- describe '#each' do
50
+ describe "#each" do
49
51
  subject do
50
52
  proc do |block|
51
53
  expect(right.each(&block)).to eq(right)
52
54
  end
53
55
  end
54
56
 
55
- it 'calls the block with value' do
56
- is_expected.to yield_with_args('value')
57
+ it "calls the block with value" do
58
+ is_expected.to yield_with_args("value")
57
59
  end
58
60
  end
59
61
 
60
- describe '#or_else' do
61
- it 'does not call block' do
62
+ describe "#or_else" do
63
+ it "does not call block" do
62
64
  expect { |probe| right.or_else(&probe) }.not_to yield_control
63
65
  end
64
66
 
65
- it 'returns the same object' do
67
+ it "returns the same object" do
66
68
  expect(right.or_else { 42 }).to eql(right)
67
69
  end
68
70
  end
69
71
 
70
- describe '#map' do
72
+ describe "#map" do
71
73
  subject { right.map(&:length) }
72
74
 
73
- it 'perform transformation' do
75
+ it "perform transformation" do
74
76
  is_expected.to eq(described_class.new(5))
75
77
  end
76
78
  end
77
79
 
78
- describe '#flat_map' do
79
- context 'block returns neither left, nor right' do
80
+ describe "#flat_map" do
81
+ context "block returns neither left, nor right" do
80
82
  subject { proc { right.flat_map { 42 } } }
81
83
 
82
- it 'fails with TypeError' do
84
+ it "fails with TypeError" do
83
85
  is_expected.to raise_error(TypeError)
84
86
  end
85
87
  end
86
88
 
87
- context 'block returns RightBiased' do
89
+ context "block returns RightBiased" do
88
90
  subject { right.flat_map { |e| described_class.new("Result: #{e}") } }
89
91
 
90
- it 'maps to block result' do
91
- is_expected.to eq(described_class.new('Result: value'))
92
+ it "maps to block result" do
93
+ is_expected.to eq(described_class.new("Result: value"))
92
94
  end
93
95
  end
94
96
  end
95
97
 
96
- describe '#to_option' do
98
+ describe "#to_option" do
97
99
  subject { right.to_option }
98
- it { is_expected.to eq(Fear::Some.new('value')) }
100
+ it { is_expected.to eq(Fear::Some.new("value")) }
99
101
  end
100
102
 
101
- describe '#any?' do
103
+ describe "#any?" do
102
104
  subject { right.any?(&predicate) }
103
105
 
104
- context 'matches predicate' do
105
- let(:predicate) { ->(v) { v == 'value' } }
106
+ context "matches predicate" do
107
+ let(:predicate) { ->(v) { v == "value" } }
106
108
  it { is_expected.to eq(true) }
107
109
  end
108
110
 
109
- context 'does not match predicate' do
110
- let(:predicate) { ->(v) { v != 'value' } }
111
+ context "does not match predicate" do
112
+ let(:predicate) { ->(v) { v != "value" } }
111
113
  it { is_expected.to eq(false) }
112
114
  end
113
115
  end
114
116
 
115
- describe '#===' do
117
+ describe "#===" do
116
118
  subject { match === right }
117
119
 
118
- context 'matches erectly' do
119
- let(:match) { described_class.new('value') }
120
+ context "matches erectly" do
121
+ let(:match) { described_class.new("value") }
120
122
  it { is_expected.to eq(true) }
121
123
  end
122
124
 
123
- context 'the same object' do
125
+ context "the same object" do
124
126
  let(:match) { right }
125
127
  it { is_expected.to eq(true) }
126
128
  end
127
129
 
128
- context 'value does not match' do
129
- let(:match) { described_class.new('error') }
130
+ context "value does not match" do
131
+ let(:match) { described_class.new("error") }
130
132
  it { is_expected.to eq(false) }
131
133
  end
132
134
 
133
- context 'matches by class' do
135
+ context "matches by class" do
134
136
  let(:match) { described_class.new(String) }
135
137
  it { is_expected.to eq(true) }
136
138
  end
137
139
 
138
- context 'does not matches by class' do
140
+ context "does not matches by class" do
139
141
  let(:match) { described_class.new(Integer) }
140
142
  it { is_expected.to eq(false) }
141
143
  end
@@ -1,76 +1,78 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Right do
2
4
  it_behaves_like Fear::RightBiased::Right do
3
- let(:right) { Fear.right('value') }
5
+ let(:right) { Fear.right("value") }
4
6
  end
5
7
 
6
- let(:right) { Fear.right('value') }
8
+ let(:right) { Fear.right("value") }
7
9
 
8
- describe '#right?' do
10
+ describe "#right?" do
9
11
  subject { right }
10
12
  it { is_expected.to be_right }
11
13
  end
12
14
 
13
- describe '#left?' do
15
+ describe "#left?" do
14
16
  subject { right }
15
17
  it { is_expected.not_to be_left }
16
18
  end
17
19
 
18
- describe '#select_or_else' do
20
+ describe "#select_or_else" do
19
21
  subject { right.select_or_else(default, &predicate) }
20
22
 
21
- context 'predicate evaluates to true' do
22
- let(:predicate) { ->(v) { v == 'value' } }
23
+ context "predicate evaluates to true" do
24
+ let(:predicate) { ->(v) { v == "value" } }
23
25
  let(:default) { -1 }
24
26
  it { is_expected.to eq(right) }
25
27
  end
26
28
 
27
- context 'predicate evaluates to false and default is a proc' do
28
- let(:predicate) { ->(v) { v != 'value' } }
29
+ context "predicate evaluates to false and default is a proc" do
30
+ let(:predicate) { ->(v) { v != "value" } }
29
31
  let(:default) { -> { -1 } }
30
32
  it { is_expected.to eq(Fear.left(-1)) }
31
33
  end
32
34
 
33
- context 'predicate evaluates to false and default is not a proc' do
34
- let(:predicate) { ->(v) { v != 'value' } }
35
+ context "predicate evaluates to false and default is not a proc" do
36
+ let(:predicate) { ->(v) { v != "value" } }
35
37
  let(:default) { -1 }
36
38
  it { is_expected.to eq(Fear.left(-1)) }
37
39
  end
38
40
  end
39
41
 
40
- describe '#select' do
42
+ describe "#select" do
41
43
  subject { right.select(&predicate) }
42
44
 
43
- context 'predicate evaluates to true' do
44
- let(:predicate) { ->(v) { v == 'value' } }
45
+ context "predicate evaluates to true" do
46
+ let(:predicate) { ->(v) { v == "value" } }
45
47
  it { is_expected.to eq(right) }
46
48
  end
47
49
 
48
- context 'predicate evaluates to false' do
49
- let(:predicate) { ->(v) { v != 'value' } }
50
- it { is_expected.to eq(Fear.left('value')) }
50
+ context "predicate evaluates to false" do
51
+ let(:predicate) { ->(v) { v != "value" } }
52
+ it { is_expected.to eq(Fear.left("value")) }
51
53
  end
52
54
  end
53
55
 
54
- describe '#reject' do
56
+ describe "#reject" do
55
57
  subject { right.reject(&predicate) }
56
58
 
57
- context 'predicate evaluates to true' do
58
- let(:predicate) { ->(v) { v == 'value' } }
59
- it { is_expected.to eq(Fear.left('value')) }
59
+ context "predicate evaluates to true" do
60
+ let(:predicate) { ->(v) { v == "value" } }
61
+ it { is_expected.to eq(Fear.left("value")) }
60
62
  end
61
63
 
62
- context 'predicate evaluates to false' do
63
- let(:predicate) { ->(v) { v != 'value' } }
64
+ context "predicate evaluates to false" do
65
+ let(:predicate) { ->(v) { v != "value" } }
64
66
  it { is_expected.to eq(right) }
65
67
  end
66
68
  end
67
69
 
68
- describe '#swap' do
70
+ describe "#swap" do
69
71
  subject { right.swap }
70
- it { is_expected.to eq(Fear.left('value')) }
72
+ it { is_expected.to eq(Fear.left("value")) }
71
73
  end
72
74
 
73
- describe '#reduce' do
75
+ describe "#reduce" do
74
76
  subject do
75
77
  right.reduce(
76
78
  ->(left) { "Left: #{left}" },
@@ -78,45 +80,45 @@ RSpec.describe Fear::Right do
78
80
  )
79
81
  end
80
82
 
81
- it { is_expected.to eq('Right: value') }
83
+ it { is_expected.to eq("Right: value") }
82
84
  end
83
85
 
84
- describe '#join_right' do
85
- context 'value is Either' do
86
+ describe "#join_right" do
87
+ context "value is Either" do
86
88
  subject { described_class.new(value).join_right }
87
- let(:value) { Fear.left('error') }
89
+ let(:value) { Fear.left("error") }
88
90
 
89
- it 'returns value' do
91
+ it "returns value" do
90
92
  is_expected.to eq(value)
91
93
  end
92
94
  end
93
95
 
94
- context 'value is not Either' do
95
- subject { proc { described_class.new('35').join_right } }
96
+ context "value is not Either" do
97
+ subject { proc { described_class.new("35").join_right } }
96
98
 
97
- it 'fails with type error' do
99
+ it "fails with type error" do
98
100
  is_expected.to raise_error(TypeError)
99
101
  end
100
102
  end
101
103
  end
102
104
 
103
- describe '#join_left' do
104
- context 'value is Either' do
105
+ describe "#join_left" do
106
+ context "value is Either" do
105
107
  subject { either.join_left }
106
- let(:either) { described_class.new(Fear.left('error')) }
108
+ let(:either) { described_class.new(Fear.left("error")) }
107
109
 
108
110
  it { is_expected.to eq(either) }
109
111
  end
110
112
 
111
- context 'value is not Either' do
113
+ context "value is not Either" do
112
114
  subject { either.join_left }
113
- let(:either) { described_class.new('result') }
115
+ let(:either) { described_class.new("result") }
114
116
  it { is_expected.to eq(either) }
115
117
  end
116
118
  end
117
119
 
118
- describe '#match' do
119
- context 'matched' do
120
+ describe "#match" do
121
+ context "matched" do
120
122
  subject do
121
123
  right.match do |m|
122
124
  m.right(->(x) { x.length < 2 }) { |x| "Right: #{x}" }
@@ -125,15 +127,15 @@ RSpec.describe Fear::Right do
125
127
  end
126
128
  end
127
129
 
128
- it { is_expected.to eq('Right: value') }
130
+ it { is_expected.to eq("Right: value") }
129
131
  end
130
132
 
131
- context 'nothing matched and no else given' do
133
+ context "nothing matched and no else given" do
132
134
  subject do
133
135
  proc do
134
136
  right.match do |m|
135
137
  m.right(->(x) { x.length < 2 }) { |x| "Right: #{x}" }
136
- m.left { |_| 'noop' }
138
+ m.left { |_| "noop" }
137
139
  end
138
140
  end
139
141
  end
@@ -141,7 +143,7 @@ RSpec.describe Fear::Right do
141
143
  it { is_expected.to raise_error(Fear::MatchError) }
142
144
  end
143
145
 
144
- context 'nothing matched and else given' do
146
+ context "nothing matched and else given" do
145
147
  subject do
146
148
  right.match do |m|
147
149
  m.right(->(x) { x.length < 2 }) { |x| "Right: #{x}" }
@@ -153,31 +155,31 @@ RSpec.describe Fear::Right do
153
155
  end
154
156
  end
155
157
 
156
- describe '#to_s' do
158
+ describe "#to_s" do
157
159
  subject { right.to_s }
158
160
 
159
161
  it { is_expected.to eq('#<Fear::Right value="value">') }
160
162
  end
161
163
 
162
- describe 'pattern matching' do
163
- subject { Fear.xcase('Right(v : Integer)') { |v:| "matched #{v}" }.call_or_else(var) { 'nothing' } }
164
+ describe "pattern matching" do
165
+ subject { Fear.xcase("Right(v : Integer)") { |v:| "matched #{v}" }.call_or_else(var) { "nothing" } }
164
166
 
165
- context 'right of int' do
167
+ context "right of int" do
166
168
  let(:var) { Fear.right(42) }
167
169
 
168
- it { is_expected.to eq('matched 42') }
170
+ it { is_expected.to eq("matched 42") }
169
171
  end
170
172
 
171
- context 'right of string' do
172
- let(:var) { Fear.right('42') }
173
+ context "right of string" do
174
+ let(:var) { Fear.right("42") }
173
175
 
174
- it { is_expected.to eq('nothing') }
176
+ it { is_expected.to eq("nothing") }
175
177
  end
176
178
 
177
- context 'not right' do
178
- let(:var) { '42' }
179
+ context "not right" do
180
+ let(:var) { "42" }
179
181
 
180
- it { is_expected.to eq('nothing') }
182
+ it { is_expected.to eq("nothing") }
181
183
  end
182
184
  end
183
185
  end