spec/async/container/shared_examples.rb in async-container-0.15.0 vs spec/async/container/shared_examples.rb in async-container-0.16.0

- old
+ new

@@ -35,11 +35,10 @@ end it "can run concurrently" do subject.async(name: "Sleepy Jerry") do |task, instance| 3.times do |i| - puts "Counting Sheep #{i}" instance.name = "Counting Sheep #{i}" sleep 0.01 end end @@ -48,19 +47,32 @@ end describe '#sleep' do it "can sleep for a short time" do subject.spawn do - sleep(2) + sleep(0.2) raise "Boom" end - subject.sleep(1) + subject.sleep(0.1) + expect(subject.statistics).to have_attributes(failures: 0) - expect(subject.statistics.failures).to be_zero - subject.wait - expect(subject.statistics.failures).to_not be_zero + expect(subject.statistics).to have_attributes(failures: 1) + end + end + + describe '#stop' do + it 'can stop the child process' do + subject.spawn do + sleep(1) + end + + is_expected.to be_running + + subject.stop + + is_expected.to_not be_running end end end