Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/futuroscope/future.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def marshal_load value
def resolved_future_value_or_raise
resolved = resolved_future_value

raise resolved[:exception] if resolved[:exception]
Kernel.raise resolved[:exception] if resolved[:exception]
resolved
end

Expand Down
14 changes: 5 additions & 9 deletions spec/futuroscope/future_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ module Futuroscope
end

it "captures exceptions and re-raises them when calling the value" do
future = Future.new{ raise "Ed Balls" }
future = Future.new { raise "Ed Balls" }

expect(lambda{
future.inspect
}).to raise_error(Exception)
expect { future.inspect }.to raise_error RuntimeError, "Ed Balls"
end

it "returns the original object when future_value gets called" do
Expand All @@ -60,11 +58,9 @@ module Futuroscope
end

it "re-raises captured exception when trying to marshal" do
future = Future.new{ raise Exception }
future = Future.new { raise "Ed Balls" }

expect(lambda{
Marshal.dump(future)
}).to raise_error(Exception)
expect { Marshal.dump(future) }.to raise_error RuntimeError, "Ed Balls"
end

it "correctly duplicates a future object" do
Expand Down Expand Up @@ -98,7 +94,7 @@ module Futuroscope
f1.future_value
f2.future_value
end
sleep 2
sleep 2.5
expect(test_thread).to_not be_alive
test_thread.kill
end
Expand Down