Sha256: f2b9918f8a863068e64617a7f92b906926ed2dfcbc967e98b8623365c0d69cc5
Contents?: true
Size: 828 Bytes
Versions: 8
Compression:
Stored size: 828 Bytes
Contents
require 'rspec/wait' RSpec.shared_examples "an interruptible input plugin" do # why 3? 2 is not enough, 4 is too much.. # a plugin that is known to be slower can override let(:allowed_lag) { 3 } describe "#stop" do let(:queue) { SizedQueue.new(20) } subject { described_class.new(config) } before(:each) { subject.register } it "returns from run" do consumer_thread = Thread.new(queue) { |queue| loop { queue.pop } } plugin_thread = Thread.new(subject, queue) { |subject, queue| subject.run(queue) } # the run method is a long lived one, so it should still be running after "a bit" sleep 0.5 expect(plugin_thread).to be_alive # now let's actually stop the plugin subject.do_stop wait(allowed_lag).for { plugin_thread }.to_not be_alive end end end
Version data entries
8 entries across 8 versions & 1 rubygems