spec/async/container/shared_examples.rb in async-container-0.14.1 vs spec/async/container/shared_examples.rb in async-container-0.15.0
- old
+ new
@@ -19,22 +19,10 @@
# THE SOFTWARE.
require 'async/rspec/reactor'
RSpec.shared_examples_for Async::Container do
- it "can attach terminator" do
- terminated = false
-
- subject.attach do
- terminated = true
- end
-
- subject.stop
-
- expect(terminated).to be_truthy
- end
-
it "can run concurrently" do
input, output = IO.pipe
subject.async do
output.write "Hello World"
@@ -55,7 +43,24 @@
sleep 0.01
end
end
subject.wait
+ end
+
+ describe '#sleep' do
+ it "can sleep for a short time" do
+ subject.spawn do
+ sleep(2)
+ raise "Boom"
+ end
+
+ subject.sleep(1)
+
+ expect(subject.statistics.failures).to be_zero
+
+ subject.wait
+
+ expect(subject.statistics.failures).to_not be_zero
+ end
end
end