@@ -162,6 +162,14 @@ def interrupt
162
162
163
163
before do
164
164
allow ( ::DRb ) . to receive ( :current_server ) { drb_server }
165
+
166
+ # To deal with some network weirdness at my workplace, I had to
167
+ # configure my network adapter in a non-standard way that causes
168
+ # `IPSocket.getaddress(Socket.gethostname)` to raise
169
+ # `SocketError: getaddrinfo: nodename nor servname provided, or not known`
170
+ # I'm not sure why this happens, but to keep the specs here passing,
171
+ # I have to stub this out :(.
172
+ allow ( IPSocket ) . to receive ( :getaddress ) { "127.0.0.1" }
165
173
end
166
174
167
175
context "when drb server is started with 127.0.0.1" do
@@ -192,27 +200,28 @@ def interrupt
192
200
it { should be_truthy }
193
201
end
194
202
195
- context "when drb server is started with another local ip address " do
203
+ context "when drb server is started with 127.0.0.1 but not alive " do
196
204
let ( :drb_server ) do
197
- instance_double ( ::DRb ::DRbServer , :uri => "druby://192.168.0.1:0000/" , :alive? => true )
198
- end
199
-
200
- before do
201
- allow ( ::IPSocket ) . to receive ( :getaddress ) . and_return ( "192.168.0.1" )
205
+ instance_double ( ::DRb ::DRbServer , :uri => "druby://127.0.0.1:0000/" , :alive? => false )
202
206
end
203
207
204
- it { should be_truthy }
208
+ it { should be_falsey }
205
209
end
206
210
207
- context "when drb server is started with 127.0.0.1 but not alive " do
211
+ context "when IPSocket cannot resolve the current hostname " do
208
212
let ( :drb_server ) do
209
- instance_double ( ::DRb ::DRbServer , :uri => "druby://127.0.0.1:0000/" , :alive? => false )
213
+ instance_double ( ::DRb ::DRbServer , :uri => "druby://localhost:0000/" , :alive? => true )
214
+ end
215
+
216
+ before do
217
+ allow ( ::IPSocket ) . to receive ( :getaddress ) . and_raise (
218
+ SocketError , "getaddrinfo: nodename nor servname provided, or not known"
219
+ )
210
220
end
211
221
212
222
it { should be_falsey }
213
223
end
214
224
215
-
216
225
context "when no drb server is running" do
217
226
let ( :drb_server ) do
218
227
raise ::DRb ::DRbServerNotFound
0 commit comments