spec/mongo/server/monitor_spec.rb in mongo-2.11.0.rc0 vs spec/mongo/server/monitor_spec.rb in mongo-2.11.0
- old
+ new
@@ -156,11 +156,11 @@
end
end
end
=end
- describe '#restart!' do
+ describe '#run!' do
let!(:thread) do
monitor.run!
end
@@ -178,9 +178,27 @@
sleep(1)
end
it 'creates a new thread' do
expect(monitor.restart!).not_to be(thread)
+ end
+ end
+
+ context 'when running after a stop' do
+ it 'starts the thread' do
+ ClientRegistry.instance.close_all_clients
+ thread
+ sleep 0.5
+
+ RSpec::Mocks.with_temporary_scope do
+ expect(monitor.connection).to receive(:disconnect!).and_call_original
+ monitor.stop!
+ sleep 0.5
+ expect(thread.alive?).to be false
+ new_thread = monitor.run!
+ sleep 0.5
+ expect(new_thread.alive?).to be(true)
+ end
end
end
end
describe '#stop' do