spec/mongo/server/monitor_spec.rb in mongo-2.0.6 vs spec/mongo/server/monitor_spec.rb in mongo-2.1.0.beta
- old
+ new
@@ -139,6 +139,36 @@
it 'refreshes the server on the provided interval' do
expect(monitor.description).to_not be_nil
end
end
+
+ describe '#restart!' do
+
+ let(:monitor) do
+ described_class.new(address, listeners, TEST_OPTIONS)
+ end
+
+ let!(:thread) do
+ monitor.run!
+ end
+
+ context 'when the monitor is already running' do
+
+ it 'does not create a new thread' do
+ expect(monitor.restart!).to be(thread)
+ end
+ end
+
+ context 'when the monitor is not already running' do
+
+ before do
+ monitor.stop!
+ sleep(1)
+ end
+
+ it 'creates a new thread' do
+ expect(monitor.restart!).not_to be(thread)
+ end
+ end
+ end
end