Skip to content

Commit f1a66d8

Browse files
committed
Add a test case for Future
* Check that future.reason is set to the Exception instance when the handler raises Exception (not StandardError)
1 parent 56209f8 commit f1a66d8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spec/concurrent/future_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ def trigger_observable(observable)
209209
expect(future.value).to be_nil
210210
end
211211

212+
it 'sets the reason to the Exception instance when the handler raises Exception' do
213+
future = Future.new(executor: executor){ raise Exception }.execute
214+
expect(future.reason).to be_a(Exception)
215+
end
216+
212217
it 'sets the state to :rejected when the handler raises an exception' do
213218
future = Future.new(executor: executor){ raise StandardError }.execute
214219
expect(future).to be_rejected

0 commit comments

Comments
 (0)