Skip to content

Commit fd56ba3

Browse files
authored
Merge pull request #685 from olleolleolle/fix/avoid-rspec-actor-spec
Avoid RSpec warnings about raise_error
2 parents d55d482 + 3e438b9 commit fd56ba3

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

spec/concurrent/actor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def on_message(message)
3333
end
3434

3535
it 'forbids Immediate executor' do
36-
expect { Utils::AdHoc.spawn! name: 'test', executor: ImmediateExecutor.new }.to raise_error
36+
expect { Utils::AdHoc.spawn! name: 'test', executor: ImmediateExecutor.new }.to raise_error(ArgumentError)
3737
end
3838

3939
describe 'spawning' do

spec/concurrent/atomic/atomic_fixnum_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
end
1212

1313
it 'raises an exception if the initial value is not a Fixnum' do
14-
expect {
15-
described_class.new(10.01)
16-
}.to raise_error
14+
expect { described_class.new(10.01) }.to(raise_error { |error|
15+
expect(error.class).to be(ArgumentError).or(be(TypeError))
16+
})
1717
end
1818
end
1919

@@ -46,7 +46,9 @@
4646
atomic = described_class.new(0)
4747
expect {
4848
atomic.value = 'foo'
49-
}.to raise_error
49+
}.to(raise_error { |error|
50+
expect(error.class).to be(ArgumentError).or(be(TypeError))
51+
})
5052
end
5153
end
5254

@@ -161,14 +163,14 @@ module Concurrent
161163

162164
it 'raises an exception if the initial value is too big' do
163165
expect {
164-
described_class.new(described_class::MAX_VALUE + 1)
165-
}.to raise_error
166+
described_class.new(Utility::NativeInteger::MAX_VALUE + 1)
167+
}.to raise_error(RangeError)
166168
end
167169

168170
it 'raises an exception if the initial value is too small' do
169171
expect {
170-
described_class.new(described_class::MIN_VALUE - 1)
171-
}.to raise_error
172+
described_class.new(Utility::NativeInteger::MIN_VALUE - 1)
173+
}.to raise_error(RangeError)
172174
end
173175
end
174176

spec/concurrent/channel_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ module Concurrent
595595
it 'raises an exception when no block is given' do
596596
expect {
597597
Channel.go_loop
598-
}.to raise_error(ArgumentError)
598+
}.to raise_error(RejectedExecutionError)
599599
end
600600

601601
it 'loops until the block returns false' do

spec/concurrent/dataflow_spec.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,16 @@ module Concurrent
7171
expect { Concurrent::dataflow_with(root_executor, nil, Future.execute{0}) }.to raise_error(ArgumentError)
7272
end
7373

74-
it 'doesn\'t raises exceptions from dependencies, unless called with !' do
75-
76-
d1 = Concurrent::dataflow(){raise}
77-
d2 = Concurrent::dataflow(){raise}
78-
f = Concurrent::dataflow!(d1, d2){|d1v, d2v| [d1v,d2v]}
79-
expect{f.value!}.to raise_error
80-
81-
d1 = Concurrent::dataflow(){raise}
82-
d2 = Concurrent::dataflow(){raise}
83-
f = Concurrent::dataflow(d1, d2){|d1v, d2v| [d1v,d2v]}
84-
expect{f.value!}.to_not raise_error
74+
it 'doesn\'t raise exceptions from dependencies, unless called with !' do
75+
d1 = Concurrent::dataflow { raise 'd1 error' }
76+
d2 = Concurrent::dataflow { raise 'd2 error' }
77+
f = Concurrent::dataflow!(d1, d2) { |d1v, d2v| [d1v, d2v] }
78+
expect { f.value! }.to raise_error(RuntimeError).with_message('d1 error')
79+
80+
d1 = Concurrent::dataflow { raise 'd1 error' }
81+
d2 = Concurrent::dataflow { raise 'd2 error' }
82+
f = Concurrent::dataflow(d1, d2) { |d1v, d2v| [d1v, d2v] }
83+
expect { f.value! }.to_not raise_error
8584
end
8685

8786
it 'returns a Future' do

spec/concurrent/executor/fixed_thread_pool_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ module Concurrent
208208
end
209209
end
210210
latch.wait(1)
211-
}.to raise_error
211+
}.to raise_error(RejectedExecutionError)
212212
end
213213

214214
# On discard, we'd expect no error, but also not all five results

spec/concurrent/timer_task_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def trigger_observable(observable)
129129
it 'raises an exception if no block given' do
130130
expect {
131131
Concurrent::TimerTask.execute
132-
}.to raise_error
132+
}.to raise_error(ArgumentError)
133133
end
134134

135135
specify '#execution_interval is writeable' do

0 commit comments

Comments
 (0)