fear 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +27 -0
  3. data/.github/workflows/rubocop.yml +39 -0
  4. data/.github/workflows/spec.yml +42 -0
  5. data/.rubocop.yml +4 -60
  6. data/.simplecov +17 -0
  7. data/CHANGELOG.md +29 -1
  8. data/Gemfile +5 -5
  9. data/Gemfile.lock +86 -50
  10. data/README.md +240 -209
  11. data/Rakefile +72 -65
  12. data/examples/pattern_extracting.rb +10 -8
  13. data/examples/pattern_matching_binary_tree_set.rb +7 -2
  14. data/examples/pattern_matching_number_in_words.rb +48 -42
  15. data/fear.gemspec +33 -34
  16. data/lib/dry/types/fear/option.rb +125 -0
  17. data/lib/dry/types/fear.rb +8 -0
  18. data/lib/fear/await.rb +33 -0
  19. data/lib/fear/awaitable.rb +28 -0
  20. data/lib/fear/either.rb +15 -4
  21. data/lib/fear/either_api.rb +4 -0
  22. data/lib/fear/either_pattern_match.rb +9 -5
  23. data/lib/fear/empty_partial_function.rb +3 -1
  24. data/lib/fear/failure.rb +7 -7
  25. data/lib/fear/failure_pattern_match.rb +4 -0
  26. data/lib/fear/for.rb +4 -2
  27. data/lib/fear/for_api.rb +5 -1
  28. data/lib/fear/future.rb +157 -82
  29. data/lib/fear/future_api.rb +17 -4
  30. data/lib/fear/left.rb +3 -9
  31. data/lib/fear/left_pattern_match.rb +2 -0
  32. data/lib/fear/none.rb +28 -10
  33. data/lib/fear/none_pattern_match.rb +2 -0
  34. data/lib/fear/option.rb +30 -2
  35. data/lib/fear/option_api.rb +4 -0
  36. data/lib/fear/option_pattern_match.rb +8 -3
  37. data/lib/fear/partial_function/and_then.rb +4 -2
  38. data/lib/fear/partial_function/any.rb +2 -0
  39. data/lib/fear/partial_function/combined.rb +3 -1
  40. data/lib/fear/partial_function/empty.rb +6 -0
  41. data/lib/fear/partial_function/guard/and.rb +2 -0
  42. data/lib/fear/partial_function/guard/and3.rb +2 -0
  43. data/lib/fear/partial_function/guard/or.rb +2 -0
  44. data/lib/fear/partial_function/guard.rb +8 -6
  45. data/lib/fear/partial_function/lifted.rb +2 -0
  46. data/lib/fear/partial_function/or_else.rb +5 -1
  47. data/lib/fear/partial_function.rb +18 -9
  48. data/lib/fear/partial_function_class.rb +3 -1
  49. data/lib/fear/pattern_match.rb +3 -11
  50. data/lib/fear/pattern_matching_api.rb +6 -28
  51. data/lib/fear/promise.rb +7 -5
  52. data/lib/fear/right.rb +3 -9
  53. data/lib/fear/right_biased.rb +5 -3
  54. data/lib/fear/right_pattern_match.rb +4 -0
  55. data/lib/fear/some.rb +35 -8
  56. data/lib/fear/some_pattern_match.rb +2 -0
  57. data/lib/fear/struct.rb +237 -0
  58. data/lib/fear/success.rb +7 -8
  59. data/lib/fear/success_pattern_match.rb +4 -0
  60. data/lib/fear/try.rb +8 -2
  61. data/lib/fear/try_api.rb +4 -0
  62. data/lib/fear/try_pattern_match.rb +9 -5
  63. data/lib/fear/unit.rb +6 -2
  64. data/lib/fear/utils.rb +14 -2
  65. data/lib/fear/version.rb +4 -1
  66. data/lib/fear.rb +26 -44
  67. data/spec/dry/types/fear/option/constrained_spec.rb +22 -0
  68. data/spec/dry/types/fear/option/core_spec.rb +77 -0
  69. data/spec/dry/types/fear/option/default_spec.rb +21 -0
  70. data/spec/dry/types/fear/option/hash_spec.rb +58 -0
  71. data/spec/dry/types/fear/option/option_spec.rb +97 -0
  72. data/spec/fear/awaitable_spec.rb +19 -0
  73. data/spec/fear/done_spec.rb +7 -5
  74. data/spec/fear/either/mixin_spec.rb +4 -2
  75. data/spec/fear/either_pattern_match_spec.rb +10 -8
  76. data/spec/fear/either_pattern_matching_spec.rb +28 -0
  77. data/spec/fear/either_spec.rb +26 -0
  78. data/spec/fear/failure_spec.rb +57 -70
  79. data/spec/fear/for/mixin_spec.rb +15 -0
  80. data/spec/fear/for_spec.rb +19 -17
  81. data/spec/fear/future_spec.rb +477 -237
  82. data/spec/fear/guard_spec.rb +136 -24
  83. data/spec/fear/left_spec.rb +57 -70
  84. data/spec/fear/none_spec.rb +39 -43
  85. data/spec/fear/option/mixin_spec.rb +9 -7
  86. data/spec/fear/option_pattern_match_spec.rb +10 -8
  87. data/spec/fear/option_pattern_matching_spec.rb +34 -0
  88. data/spec/fear/option_spec.rb +142 -0
  89. data/spec/fear/partial_function/any_spec.rb +25 -0
  90. data/spec/fear/partial_function/empty_spec.rb +12 -10
  91. data/spec/fear/partial_function_and_then_spec.rb +39 -37
  92. data/spec/fear/partial_function_composition_spec.rb +46 -44
  93. data/spec/fear/partial_function_or_else_spec.rb +92 -90
  94. data/spec/fear/partial_function_spec.rb +91 -61
  95. data/spec/fear/pattern_match_spec.rb +19 -51
  96. data/spec/fear/pattern_matching_api_spec.rb +31 -0
  97. data/spec/fear/promise_spec.rb +23 -23
  98. data/spec/fear/right_biased/left.rb +28 -26
  99. data/spec/fear/right_biased/right.rb +51 -49
  100. data/spec/fear/right_spec.rb +48 -68
  101. data/spec/fear/some_spec.rb +30 -40
  102. data/spec/fear/success_spec.rb +40 -60
  103. data/spec/fear/try/mixin_spec.rb +19 -3
  104. data/spec/fear/try_api_spec.rb +23 -0
  105. data/spec/fear/try_pattern_match_spec.rb +10 -8
  106. data/spec/fear/try_pattern_matching_spec.rb +34 -0
  107. data/spec/fear/utils_spec.rb +16 -14
  108. data/spec/spec_helper.rb +13 -7
  109. data/spec/struct_pattern_matching_spec.rb +36 -0
  110. data/spec/struct_spec.rb +194 -0
  111. data/spec/support/dry_types.rb +6 -0
  112. metadata +128 -87
  113. data/.travis.yml +0 -13
  114. data/lib/fear/extractor/anonymous_array_splat_matcher.rb +0 -8
  115. data/lib/fear/extractor/any_matcher.rb +0 -15
  116. data/lib/fear/extractor/array_head_matcher.rb +0 -34
  117. data/lib/fear/extractor/array_matcher.rb +0 -38
  118. data/lib/fear/extractor/array_splat_matcher.rb +0 -14
  119. data/lib/fear/extractor/empty_list_matcher.rb +0 -18
  120. data/lib/fear/extractor/extractor_matcher.rb +0 -42
  121. data/lib/fear/extractor/grammar.rb +0 -201
  122. data/lib/fear/extractor/grammar.treetop +0 -129
  123. data/lib/fear/extractor/identifier_matcher.rb +0 -16
  124. data/lib/fear/extractor/matcher/and.rb +0 -36
  125. data/lib/fear/extractor/matcher.rb +0 -54
  126. data/lib/fear/extractor/named_array_splat_matcher.rb +0 -15
  127. data/lib/fear/extractor/pattern.rb +0 -55
  128. data/lib/fear/extractor/typed_identifier_matcher.rb +0 -24
  129. data/lib/fear/extractor/value_matcher.rb +0 -17
  130. data/lib/fear/extractor.rb +0 -108
  131. data/lib/fear/extractor_api.rb +0 -33
  132. data/spec/fear/extractor/array_matcher_spec.rb +0 -228
  133. data/spec/fear/extractor/extractor_matcher_spec.rb +0 -151
  134. data/spec/fear/extractor/grammar_array_spec.rb +0 -23
  135. data/spec/fear/extractor/identified_matcher_spec.rb +0 -47
  136. data/spec/fear/extractor/identifier_matcher_spec.rb +0 -66
  137. data/spec/fear/extractor/pattern_spec.rb +0 -32
  138. data/spec/fear/extractor/typed_identifier_matcher_spec.rb +0 -62
  139. data/spec/fear/extractor/value_matcher_number_spec.rb +0 -77
  140. data/spec/fear/extractor/value_matcher_string_spec.rb +0 -86
  141. data/spec/fear/extractor/value_matcher_symbol_spec.rb +0 -69
  142. data/spec/fear/extractor_api_spec.rb +0 -113
  143. data/spec/fear/extractor_spec.rb +0 -59
@@ -1,39 +1,7 @@
1
- RSpec.describe Fear::PatternMatch do
2
- context 'extracting' do
3
- let(:matcher) do
4
- described_class.new do |m|
5
- m.xcase('Date(year, 2, 29)', ->(year:) { year < 2000 }) do |year:|
6
- "#{year} is a leap year before Millennium"
7
- end
8
- m.xcase('Date(year, 2, 29)') do |year:|
9
- "#{year} is a leap year after Millennium"
10
- end
11
- m.case(Date) do |date|
12
- "#{date.year} is not a leap year"
13
- end
14
- end
15
- end
16
-
17
- context 'before Millennium' do
18
- subject { matcher.call(Date.parse('1996-02-29')) }
19
-
20
- it { is_expected.to eq('1996 is a leap year before Millennium') }
21
- end
1
+ # frozen_string_literal: true
22
2
 
23
- context 'after Millennium' do
24
- subject { matcher.call(Date.parse('2004-02-29')) }
25
-
26
- it { is_expected.to eq('2004 is a leap year after Millennium') }
27
- end
28
-
29
- context 'not leap' do
30
- subject { matcher.call(Date.parse('2003-01-24')) }
31
-
32
- it { is_expected.to eq('2003 is not a leap year') }
33
- end
34
- end
35
-
36
- context 'else at the end' do
3
+ RSpec.describe Fear::PatternMatch do
4
+ context "else at the end" do
37
5
  let(:matcher) do
38
6
  described_class.new do |m|
39
7
  m.case(Integer) { |x| "#{x} is int" }
@@ -42,27 +10,27 @@ RSpec.describe Fear::PatternMatch do
42
10
  end
43
11
  end
44
12
 
45
- context 'Integer' do
46
- subject { matcher.call(4) }
13
+ context "Integer" do
14
+ subject { matcher.(4) }
47
15
 
48
- it { is_expected.to eq('4 is int') }
16
+ it { is_expected.to eq("4 is int") }
49
17
  end
50
18
 
51
- context 'String' do
52
- subject { matcher.call('4') }
19
+ context "String" do
20
+ subject { matcher.("4") }
53
21
 
54
- it { is_expected.to eq('4 is str') }
22
+ it { is_expected.to eq("4 is str") }
55
23
  end
56
24
 
57
- context 'Symbol' do
58
- subject { matcher.call(:a) }
25
+ context "Symbol" do
26
+ subject { matcher.(:a) }
59
27
 
60
- it { is_expected.to eq('a is something else') }
28
+ it { is_expected.to eq("a is something else") }
61
29
  end
62
30
  end
63
31
 
64
- context 'else before other branches' do
65
- subject { matcher.call(4) }
32
+ context "else before other branches" do
33
+ subject { matcher.(4) }
66
34
 
67
35
  let(:matcher) do
68
36
  described_class.new do |m|
@@ -71,11 +39,11 @@ RSpec.describe Fear::PatternMatch do
71
39
  end
72
40
  end
73
41
 
74
- it { is_expected.to eq('4 is something else') }
42
+ it { is_expected.to eq("4 is something else") }
75
43
  end
76
44
 
77
- context 'several else branches' do
78
- subject { matcher.call(4) }
45
+ context "several else branches" do
46
+ subject { matcher.(4) }
79
47
 
80
48
  let(:matcher) do
81
49
  described_class.new do |m|
@@ -84,8 +52,8 @@ RSpec.describe Fear::PatternMatch do
84
52
  end
85
53
  end
86
54
 
87
- it 'first one wins' do
88
- is_expected.to eq('4 else 1')
55
+ it "first one wins" do
56
+ is_expected.to eq("4 else 1")
89
57
  end
90
58
  end
91
59
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Fear::PatternMatchingApi do
4
+ describe "Fear.match" do
5
+ subject do
6
+ Fear.match(value) do |m|
7
+ m.case(Integer, :even?.to_proc) { |x| "#{x} is even" }
8
+ m.case(Integer, :odd?.to_proc) { |x| "#{x} is odd" }
9
+ m.else { |x| "#{x} is not a number" }
10
+ end
11
+ end
12
+
13
+ context "when one branch matches" do
14
+ let(:value) { 42 }
15
+
16
+ it { is_expected.to eq("42 is even") }
17
+ end
18
+
19
+ context "when another branch matches" do
20
+ let(:value) { 21 }
21
+
22
+ it { is_expected.to eq("21 is odd") }
23
+ end
24
+
25
+ context "when else matches" do
26
+ let(:value) { "foo" }
27
+
28
+ it { is_expected.to eq("foo is not a number") }
29
+ end
30
+ end
31
+ end
@@ -1,93 +1,93 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Promise do
2
4
  let(:value) { 42 }
3
- let(:error) { StandardError.new('something went wrong') }
5
+ let(:error) { StandardError.new("something went wrong") }
4
6
 
5
7
  def not_completed_promise
6
8
  Fear::Promise.new(executor: Concurrent::ImmediateExecutor.new)
7
9
  end
8
10
 
9
- context 'not completed' do
10
- it '#success! returns self' do
11
+ context "not completed" do
12
+ it "#success! returns self" do
11
13
  completed_promise = not_completed_promise.success!(value)
12
14
 
13
15
  expect(completed_promise).to eq completed_promise
14
16
  end
15
17
 
16
- it '#success returns true' do
18
+ it "#success returns true" do
17
19
  completed = not_completed_promise.success(value)
18
20
 
19
21
  expect(completed).to be true
20
22
  end
21
23
 
22
- it '#failure! returns self' do
24
+ it "#failure! returns self" do
23
25
  completed_promise = not_completed_promise.failure!(error)
24
26
 
25
27
  expect(completed_promise).to eq completed_promise
26
28
  end
27
29
 
28
- it '#failure returns true' do
30
+ it "#failure returns true" do
29
31
  completed = not_completed_promise.failure(error)
30
32
 
31
33
  expect(completed).to be true
32
34
  end
33
35
 
34
- it '#completed? returns true' do
36
+ it "#completed? returns true" do
35
37
  expect(not_completed_promise).not_to be_completed
36
38
  end
37
39
 
38
- it '#future returns not completed future' do
40
+ it "#future returns not completed future" do
39
41
  future = not_completed_promise.to_future
40
42
 
41
43
  expect(future).not_to be_completed
42
44
  end
43
45
  end
44
46
 
45
- context 'completed' do
47
+ context "completed" do
46
48
  def completed_promise
47
49
  not_completed_promise.success!(value)
48
50
  end
49
51
 
50
- it '#success! fails with exception' do
52
+ it "#success! fails with exception" do
51
53
  expect do
52
54
  completed_promise.success!(value)
53
55
  end.to raise_exception(Fear::IllegalStateException)
54
56
  end
55
57
 
56
- it '#success returns false' do
58
+ it "#success returns false" do
57
59
  completed = completed_promise.success(value)
58
60
 
59
61
  expect(completed).to be false
60
62
  end
61
63
 
62
- it '#failure! fails with exception' do
64
+ it "#failure! fails with exception" do
63
65
  expect do
64
66
  completed_promise.failure!(error)
65
67
  end.to raise_exception(Fear::IllegalStateException)
66
68
  end
67
69
 
68
- it '#failure returns false' do
70
+ it "#failure returns false" do
69
71
  completed = completed_promise.success(error)
70
72
 
71
73
  expect(completed).to be false
72
74
  end
73
75
 
74
- it '#completed? returns true' do
76
+ it "#completed? returns true" do
75
77
  expect(completed_promise).to be_completed
76
78
  end
77
79
 
78
- context '#future' do
79
- subject(:future) do
80
- completed_promise.to_future
81
- end
80
+ context "#future" do
81
+ subject(:future) { Fear::Await.ready(promise.to_future, 0.01) }
82
82
 
83
- it 'is completed' do
83
+ let(:promise) { Fear::Promise.new.success!(value) }
84
+
85
+ it "is completed" do
84
86
  expect(future).to be_completed
85
87
  end
86
88
 
87
- it 'completed with value' do
88
- future_value = future.value
89
-
90
- expect(future_value).to eq Fear.some(Fear.success(value))
89
+ it "completed with value" do
90
+ expect(future.value).to be_some_of(Fear.success(value))
91
91
  end
92
92
  end
93
93
  end
@@ -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