Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid RSpec warnings about raise_error #685

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/concurrent/actor_spec.rb
Expand Up @@ -33,7 +33,7 @@ def on_message(message)
end

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

describe 'spawning' do
Expand Down
18 changes: 10 additions & 8 deletions spec/concurrent/atomic/atomic_fixnum_spec.rb
Expand Up @@ -11,9 +11,9 @@
end

it 'raises an exception if the initial value is not a Fixnum' do
expect {
described_class.new(10.01)
}.to raise_error
expect { described_class.new(10.01) }.to(raise_error { |error|
expect(error.class).to be(ArgumentError).or(be(TypeError))
})
end
end

Expand Down Expand Up @@ -46,7 +46,9 @@
atomic = described_class.new(0)
expect {
atomic.value = 'foo'
}.to raise_error
}.to(raise_error { |error|
expect(error.class).to be(ArgumentError).or(be(TypeError))
})
end
end

Expand Down Expand Up @@ -161,14 +163,14 @@ module Concurrent

it 'raises an exception if the initial value is too big' do
expect {
described_class.new(described_class::MAX_VALUE + 1)
}.to raise_error
described_class.new(Utility::NativeInteger::MAX_VALUE + 1)
}.to raise_error(RangeError)
end

it 'raises an exception if the initial value is too small' do
expect {
described_class.new(described_class::MIN_VALUE - 1)
}.to raise_error
described_class.new(Utility::NativeInteger::MIN_VALUE - 1)
}.to raise_error(RangeError)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/concurrent/channel_spec.rb
Expand Up @@ -595,7 +595,7 @@ module Concurrent
it 'raises an exception when no block is given' do
expect {
Channel.go_loop
}.to raise_error(ArgumentError)
}.to raise_error(RejectedExecutionError)
end

it 'loops until the block returns false' do
Expand Down
21 changes: 10 additions & 11 deletions spec/concurrent/dataflow_spec.rb
Expand Up @@ -71,17 +71,16 @@ module Concurrent
expect { Concurrent::dataflow_with(root_executor, nil, Future.execute{0}) }.to raise_error(ArgumentError)
end

it 'doesn\'t raises exceptions from dependencies, unless called with !' do

d1 = Concurrent::dataflow(){raise}
d2 = Concurrent::dataflow(){raise}
f = Concurrent::dataflow!(d1, d2){|d1v, d2v| [d1v,d2v]}
expect{f.value!}.to raise_error

d1 = Concurrent::dataflow(){raise}
d2 = Concurrent::dataflow(){raise}
f = Concurrent::dataflow(d1, d2){|d1v, d2v| [d1v,d2v]}
expect{f.value!}.to_not raise_error
it 'doesn\'t raise exceptions from dependencies, unless called with !' do
d1 = Concurrent::dataflow { raise 'd1 error' }
d2 = Concurrent::dataflow { raise 'd2 error' }
f = Concurrent::dataflow!(d1, d2) { |d1v, d2v| [d1v, d2v] }
expect { f.value! }.to raise_error(RuntimeError).with_message('d1 error')

d1 = Concurrent::dataflow { raise 'd1 error' }
d2 = Concurrent::dataflow { raise 'd2 error' }
f = Concurrent::dataflow(d1, d2) { |d1v, d2v| [d1v, d2v] }
expect { f.value! }.to_not raise_error
end

it 'returns a Future' do
Expand Down
2 changes: 1 addition & 1 deletion spec/concurrent/executor/fixed_thread_pool_spec.rb
Expand Up @@ -208,7 +208,7 @@ module Concurrent
end
end
latch.wait(1)
}.to raise_error
}.to raise_error(RejectedExecutionError)
end

# On discard, we'd expect no error, but also not all five results
Expand Down
2 changes: 1 addition & 1 deletion spec/concurrent/timer_task_spec.rb
Expand Up @@ -129,7 +129,7 @@ def trigger_observable(observable)
it 'raises an exception if no block given' do
expect {
Concurrent::TimerTask.execute
}.to raise_error
}.to raise_error(ArgumentError)
end

specify '#execution_interval is writeable' do
Expand Down