1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Socket::Unix do
require_unix_socket
let(:path) { "/tmp/mongodb-#{SpecConfig.instance.any_port}.sock" }
let(:socket) do
described_class.new(path, 5)
end
describe '#human_address' do
it 'returns the path' do
expect(socket.send(:human_address)).to eq(path)
end
end
describe '#connect!' do
after do
socket.close
end
it 'connects to the server' do
expect(socket).to be_alive
end
end
describe '#alive?' do
context 'when the socket is connected' do
after do
socket.close
end
it 'returns true' do
expect(socket).to be_alive
end
end
context 'when the socket is not connected' do
before do
socket.close
end
it 'raises error' do
expect { socket.alive? }.to raise_error(IOError)
end
end
end
end
|