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,71 +1,73 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Some do
2
4
  it_behaves_like Fear::RightBiased::Right do
3
- let(:right) { Fear.some('value') }
5
+ let(:right) { Fear.some("value") }
4
6
  end
5
7
 
6
8
  subject(:some) { Fear.some(42) }
7
9
 
8
- describe '#select' do
10
+ describe "#select" do
9
11
  subject { some.select(&predicate) }
10
12
 
11
- context 'predicate evaluates to true' do
13
+ context "predicate evaluates to true" do
12
14
  let(:predicate) { ->(v) { v > 40 } }
13
15
  it { is_expected.to eq(some) }
14
16
  end
15
17
 
16
- context 'predicate evaluates to false' do
18
+ context "predicate evaluates to false" do
17
19
  let(:predicate) { ->(v) { v < 40 } }
18
20
  it { is_expected.to eq(Fear.none) }
19
21
  end
20
22
  end
21
23
 
22
- describe '#reject' do
24
+ describe "#reject" do
23
25
  subject { some.reject(&predicate) }
24
26
 
25
- context 'predicate evaluates to true' do
27
+ context "predicate evaluates to true" do
26
28
  let(:predicate) { ->(v) { v > 40 } }
27
29
  it { is_expected.to eq(Fear.none) }
28
30
  end
29
31
 
30
- context 'predicate evaluates to false' do
32
+ context "predicate evaluates to false" do
31
33
  let(:predicate) { ->(v) { v < 40 } }
32
34
  it { is_expected.to eq(some) }
33
35
  end
34
36
  end
35
37
 
36
- describe '#get' do
38
+ describe "#get" do
37
39
  subject { some.get }
38
40
  it { is_expected.to eq(42) }
39
41
  end
40
42
 
41
- describe '#or_nil' do
43
+ describe "#or_nil" do
42
44
  subject { some.or_nil }
43
45
  it { is_expected.to eq(42) }
44
46
  end
45
47
 
46
- describe '#empty?' do
48
+ describe "#empty?" do
47
49
  subject { some.empty? }
48
50
  it { is_expected.to eq(false) }
49
51
  end
50
52
 
51
- describe '#match' do
52
- context 'matched' do
53
+ describe "#match" do
54
+ context "matched" do
53
55
  subject do
54
56
  some.match do |m|
55
57
  m.some(->(x) { x > 2 }) { |x| x * 2 }
56
- m.none { 'noop' }
58
+ m.none { "noop" }
57
59
  end
58
60
  end
59
61
 
60
62
  it { is_expected.to eq(84) }
61
63
  end
62
64
 
63
- context 'nothing matched and no else given' do
65
+ context "nothing matched and no else given" do
64
66
  subject do
65
67
  proc do
66
68
  some.match do |m|
67
69
  m.some(->(x) { x < 2 }) { |x| x * 2 }
68
- m.none { 'noop' }
70
+ m.none { "noop" }
69
71
  end
70
72
  end
71
73
  end
@@ -73,7 +75,7 @@ RSpec.describe Fear::Some do
73
75
  it { is_expected.to raise_error(Fear::MatchError) }
74
76
  end
75
77
 
76
- context 'nothing matched and else given' do
78
+ context "nothing matched and else given" do
77
79
  subject do
78
80
  some.match do |m|
79
81
  m.none { |x| x * 2 }
@@ -85,31 +87,31 @@ RSpec.describe Fear::Some do
85
87
  end
86
88
  end
87
89
 
88
- describe '#to_s' do
90
+ describe "#to_s" do
89
91
  subject { some.to_s }
90
92
 
91
- it { is_expected.to eq('#<Fear::Some get=42>') }
93
+ it { is_expected.to eq("#<Fear::Some get=42>") }
92
94
  end
93
95
 
94
- describe 'pattern matching' do
95
- subject { Fear.xcase('Some(v : Integer)') { |v:| "matched #{v}" }.call_or_else(var) { 'nothing' } }
96
+ describe "pattern matching" do
97
+ subject { Fear.xcase("Some(v : Integer)") { |v:| "matched #{v}" }.call_or_else(var) { "nothing" } }
96
98
 
97
- context 'some of int' do
99
+ context "some of int" do
98
100
  let(:var) { Fear.some(42) }
99
101
 
100
- it { is_expected.to eq('matched 42') }
102
+ it { is_expected.to eq("matched 42") }
101
103
  end
102
104
 
103
- context 'some of string' do
104
- let(:var) { Fear.some('42') }
105
+ context "some of string" do
106
+ let(:var) { Fear.some("42") }
105
107
 
106
- it { is_expected.to eq('nothing') }
108
+ it { is_expected.to eq("nothing") }
107
109
  end
108
110
 
109
- context 'not some' do
110
- let(:var) { '42' }
111
+ context "not some" do
112
+ let(:var) { "42" }
111
113
 
112
- it { is_expected.to eq('nothing') }
114
+ it { is_expected.to eq("nothing") }
113
115
  end
114
116
  end
115
117
  end
@@ -1,114 +1,116 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Success do
2
- let(:success) { Fear.success('value') }
4
+ let(:success) { Fear.success("value") }
3
5
 
4
6
  it_behaves_like Fear::RightBiased::Right do
5
7
  let(:right) { success }
6
8
 
7
- describe '#map', 'block fails' do
8
- subject(:map) { right.map { raise 'unexpected error' } }
9
+ describe "#map", "block fails" do
10
+ subject(:map) { right.map { raise "unexpected error" } }
9
11
 
10
12
  it { is_expected.to be_kind_of(Fear::Failure) }
11
- it { expect { map.get }.to raise_error(RuntimeError, 'unexpected error') }
13
+ it { expect { map.get }.to raise_error(RuntimeError, "unexpected error") }
12
14
  end
13
15
 
14
- describe '#flat_map', 'block fails' do
15
- subject(:flat_map) { right.flat_map { raise 'unexpected error' } }
16
+ describe "#flat_map", "block fails" do
17
+ subject(:flat_map) { right.flat_map { raise "unexpected error" } }
16
18
 
17
19
  it { is_expected.to be_kind_of(Fear::Failure) }
18
- it { expect { flat_map.get }.to raise_error(RuntimeError, 'unexpected error') }
20
+ it { expect { flat_map.get }.to raise_error(RuntimeError, "unexpected error") }
19
21
  end
20
22
  end
21
23
 
22
- describe '#get' do
24
+ describe "#get" do
23
25
  subject { success.get }
24
- it { is_expected.to eq('value') }
26
+ it { is_expected.to eq("value") }
25
27
  end
26
28
 
27
- describe '#success?' do
29
+ describe "#success?" do
28
30
  subject { success }
29
31
  it { is_expected.to be_success }
30
32
  end
31
33
 
32
- describe '#failure?' do
34
+ describe "#failure?" do
33
35
  subject { success }
34
36
  it { is_expected.not_to be_failure }
35
37
  end
36
38
 
37
- describe '#or_else' do
38
- subject { success.or_else { described_class.new('another value') } }
39
+ describe "#or_else" do
40
+ subject { success.or_else { described_class.new("another value") } }
39
41
  it { is_expected.to eq(success) }
40
42
  end
41
43
 
42
- describe '#flatten' do
44
+ describe "#flatten" do
43
45
  subject { described_class.new(value).flatten }
44
46
 
45
- context 'value is a Success' do
47
+ context "value is a Success" do
46
48
  let(:value) { described_class.new(42) }
47
49
  it { is_expected.to eq(described_class.new(42)) }
48
50
  end
49
51
 
50
- context 'value is a Success of Success' do
52
+ context "value is a Success of Success" do
51
53
  let(:value) { described_class.new(described_class.new(42)) }
52
54
  it { is_expected.to eq(described_class.new(42)) }
53
55
  end
54
56
 
55
- context 'value is a Success of Failure' do
57
+ context "value is a Success of Failure" do
56
58
  let(:failure) { Fear::Failure.new(RuntimeError.new) }
57
59
  let(:value) { described_class.new(failure) }
58
60
  it { is_expected.to eq(failure) }
59
61
  end
60
62
  end
61
63
 
62
- describe '#select' do
63
- context 'predicate holds for value' do
64
- subject { success.select { |v| v == 'value' } }
64
+ describe "#select" do
65
+ context "predicate holds for value" do
66
+ subject { success.select { |v| v == "value" } }
65
67
  it { is_expected.to eq(success) }
66
68
  end
67
69
 
68
- context 'predicate does not hold for value' do
69
- subject { proc { success.select { |v| v != 'value' }.get } } # rubocop: disable Style/InverseMethods
70
- it { is_expected.to raise_error(Fear::NoSuchElementError, 'Predicate does not hold for `value`') }
70
+ context "predicate does not hold for value" do
71
+ subject { proc { success.select { |v| v != "value" }.get } }
72
+ it { is_expected.to raise_error(Fear::NoSuchElementError, "Predicate does not hold for `value`") }
71
73
  end
72
74
 
73
- context 'predicate fails with error' do
74
- subject { proc { success.select { raise 'foo' }.get } }
75
- it { is_expected.to raise_error(RuntimeError, 'foo') }
75
+ context "predicate fails with error" do
76
+ subject { proc { success.select { raise "foo" }.get } }
77
+ it { is_expected.to raise_error(RuntimeError, "foo") }
76
78
  end
77
79
  end
78
80
 
79
- describe '#recover_with' do
81
+ describe "#recover_with" do
80
82
  subject { success.recover_with { |v| Fear.success(v * 2) } }
81
83
  it { is_expected.to eq(success) }
82
84
  end
83
85
 
84
- describe '#recover' do
86
+ describe "#recover" do
85
87
  subject { success.recover { |m| m.case { |v| v * 2 } } }
86
88
  it { is_expected.to eq(success) }
87
89
  end
88
90
 
89
- describe '#to_either' do
91
+ describe "#to_either" do
90
92
  subject { success.to_either }
91
- it { is_expected.to eq(Fear.right('value')) }
93
+ it { is_expected.to eq(Fear.right("value")) }
92
94
  end
93
95
 
94
- describe '#match' do
95
- context 'matched' do
96
+ describe "#match" do
97
+ context "matched" do
96
98
  subject do
97
99
  success.match do |m|
98
100
  m.success(->(x) { x.length > 2 }) { |x| x * 2 }
99
- m.failure { 'noop' }
101
+ m.failure { "noop" }
100
102
  end
101
103
  end
102
104
 
103
- it { is_expected.to eq('valuevalue') }
105
+ it { is_expected.to eq("valuevalue") }
104
106
  end
105
107
 
106
- context 'nothing matched and no else given' do
108
+ context "nothing matched and no else given" do
107
109
  subject do
108
110
  proc do
109
111
  success.match do |m|
110
112
  m.success(->(x) { x.length < 2 }) { |x| x * 2 }
111
- m.failure { 'noop' }
113
+ m.failure { "noop" }
112
114
  end
113
115
  end
114
116
  end
@@ -116,7 +118,7 @@ RSpec.describe Fear::Success do
116
118
  it { is_expected.to raise_error(Fear::MatchError) }
117
119
  end
118
120
 
119
- context 'nothing matched and else given' do
121
+ context "nothing matched and else given" do
120
122
  subject do
121
123
  success.match do |m|
122
124
  m.failure { |x| x * 2 }
@@ -128,31 +130,31 @@ RSpec.describe Fear::Success do
128
130
  end
129
131
  end
130
132
 
131
- describe '#to_s' do
133
+ describe "#to_s" do
132
134
  subject { success.to_s }
133
135
 
134
136
  it { is_expected.to eq('#<Fear::Success value="value">') }
135
137
  end
136
138
 
137
- describe 'pattern matching' do
138
- subject { Fear.xcase('Success(v : Integer)') { |v:| "matched #{v}" }.call_or_else(var) { 'nothing' } }
139
+ describe "pattern matching" do
140
+ subject { Fear.xcase("Success(v : Integer)") { |v:| "matched #{v}" }.call_or_else(var) { "nothing" } }
139
141
 
140
- context 'success of int' do
142
+ context "success of int" do
141
143
  let(:var) { Fear.success(42) }
142
144
 
143
- it { is_expected.to eq('matched 42') }
145
+ it { is_expected.to eq("matched 42") }
144
146
  end
145
147
 
146
- context 'success of string' do
147
- let(:var) { Fear.success('42') }
148
+ context "success of string" do
149
+ let(:var) { Fear.success("42") }
148
150
 
149
- it { is_expected.to eq('nothing') }
151
+ it { is_expected.to eq("nothing") }
150
152
  end
151
153
 
152
- context 'not success' do
153
- let(:var) { '42' }
154
+ context "not success" do
155
+ let(:var) { "42" }
154
156
 
155
- it { is_expected.to eq('nothing') }
157
+ it { is_expected.to eq("nothing") }
156
158
  end
157
159
  end
158
160
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Try::Mixin do
2
4
  include Fear::Try::Mixin
3
5
 
4
- describe 'Try()' do
5
- context 'success' do
6
+ describe "Try()" do
7
+ context "success" do
6
8
  subject { Try { 4 / 2 } }
7
9
 
8
10
  it { is_expected.to eq(Fear::Success.new(2)) }
9
11
  end
10
12
 
11
- context 'failure' do
13
+ context "failure" do
12
14
  subject { Try { 4 / 0 } }
13
15
 
14
16
  it { is_expected.to be_kind_of(Fear::Failure) }
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::TryPatternMatch do
2
- context 'Success' do
4
+ context "Success" do
3
5
  let(:matcher) do
4
6
  described_class.new do |m|
5
7
  m.success(:even?.to_proc) { |x| "#{x} is even" }
@@ -8,15 +10,15 @@ RSpec.describe Fear::TryPatternMatch do
8
10
  end
9
11
 
10
12
  it do
11
- expect(matcher.call(Fear.success(4))).to eq('4 is even')
12
- expect(matcher.call(Fear.success(3))).to eq('3 is odd')
13
+ expect(matcher.(Fear.success(4))).to eq("4 is even")
14
+ expect(matcher.(Fear.success(3))).to eq("3 is odd")
13
15
  expect do
14
- matcher.call(Fear.failure(RuntimeError.new))
16
+ matcher.(Fear.failure(RuntimeError.new))
15
17
  end.to raise_error(Fear::MatchError)
16
18
  end
17
19
  end
18
20
 
19
- context 'Failure' do
21
+ context "Failure" do
20
22
  let(:matcher) do
21
23
  described_class.new do |m|
22
24
  m.failure(RuntimeError) { |x| "#{x} is first" }
@@ -25,10 +27,10 @@ RSpec.describe Fear::TryPatternMatch do
25
27
  end
26
28
 
27
29
  it do
28
- expect(matcher.call(Fear.failure(RuntimeError.new))).to eq('RuntimeError is first')
29
- expect(matcher.call(Fear.failure(StandardError.new))).to eq('StandardError is second')
30
+ expect(matcher.(Fear.failure(RuntimeError.new))).to eq("RuntimeError is first")
31
+ expect(matcher.(Fear.failure(StandardError.new))).to eq("StandardError is second")
30
32
  expect do
31
- matcher.call(Fear.success(44))
33
+ matcher.(Fear.success(44))
32
34
  end.to raise_error(Fear::MatchError)
33
35
  end
34
36
  end
@@ -1,58 +1,60 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.describe Fear::Utils do
2
- describe '.assert_arg_or_block!' do
4
+ describe ".assert_arg_or_block!" do
3
5
  def assert_arg_or_block!(*args, &block)
4
6
  described_class.assert_arg_or_block!(:the_method, *args, &block)
5
7
  end
6
8
 
7
- context 'block given, argument does not given' do
9
+ context "block given, argument does not given" do
8
10
  subject { proc { assert_arg_or_block! {} } }
9
11
 
10
12
  it { is_expected.not_to raise_error }
11
13
  end
12
14
 
13
- context 'argument given, block does not given' do
15
+ context "argument given, block does not given" do
14
16
  subject { proc { assert_arg_or_block!(42) } }
15
17
 
16
18
  it { is_expected.not_to raise_error }
17
19
  end
18
20
 
19
- context 'argument and block given at the same time' do
21
+ context "argument and block given at the same time" do
20
22
  subject { proc { assert_arg_or_block!(42) {} } }
21
23
 
22
- it 'fails with argument error' do
24
+ it "fails with argument error" do
23
25
  is_expected.to raise_error(
24
26
  ArgumentError,
25
- '#the_method accepts either one argument or block',
27
+ "#the_method accepts either one argument or block",
26
28
  )
27
29
  end
28
30
  end
29
31
 
30
- context 'no argument and no block given' do
32
+ context "no argument and no block given" do
31
33
  subject { proc { assert_arg_or_block! } }
32
34
 
33
- it 'fails with argument error' do
35
+ it "fails with argument error" do
34
36
  is_expected.to raise_error(
35
37
  ArgumentError,
36
- '#the_method accepts either one argument or block',
38
+ "#the_method accepts either one argument or block",
37
39
  )
38
40
  end
39
41
  end
40
42
  end
41
43
 
42
- describe 'assert_type!' do
43
- context 'value is of the given type' do
44
+ describe "assert_type!" do
45
+ context "value is of the given type" do
44
46
  subject { proc { described_class.assert_type!(24, Integer) } }
45
47
 
46
48
  it { is_expected.not_to raise_error }
47
49
  end
48
50
 
49
- context 'value is not of the given type' do
51
+ context "value is not of the given type" do
50
52
  subject { proc { described_class.assert_type!(24, String) } }
51
53
 
52
- it 'raises TypeError' do
54
+ it "raises TypeError" do
53
55
  is_expected.to raise_error(
54
56
  TypeError,
55
- 'expected `24` to be of String class',
57
+ "expected `24` to be of String class",
56
58
  )
57
59
  end
58
60
  end