Subject: | t/02connect test cases unexpectedly pass; Can't connect to "www.simplymapped.com" |
The test cases in t/02connect.t unexpectedly pass even though www.simplymapped.com
cannot currently be found in the DNS:
t/02connect........ok 1/4Can't load http://www.simplymapped.com/services/geocode/
json.smd: 500 Can't connect to www.simplymapped.com:80 (Bad hostname
'www.simplymapped.com') at t/02connect.t line 9
t/02connect........ok 2/4Can't load http://www.simplymapped.com/services/geocode/
json.smd: 500 Can't connect to www.simplymapped.com:80 (Bad hostname
'www.simplymapped.com') at t/02connect.t line 13
t/02connect........ok 3/4Can't load http://www.simplymapped.com/services/geocode/
json.smd: 500 Can't connect to www.simplymapped.com:80 (Bad hostname
'www.simplymapped.com') at t/02connect.t line 17
t/02connect........ok
This is because RPC::JSON->new() always returns an object, which stringifies to pass the test
case:
ok($jsonrpc2, "Creating RPC::JSON object with hash");
Suggested fix (aside from having a valid hostname in the test cases):
--- lib/RPC/JSON.pm.dist 2006-08-20 23:37:37.000000000 +1000
+++ lib/RPC/JSON.pm 2007-05-22 07:36:18.000000000 +1000
@@ -134,7 +134,7 @@
unless ( $self->{dont_connect} ) {
# If we fail to connect, it will alert the user but we shouldn't cancel
# the object (or maybe we should if it is a 40* error?)
- $self->connect;
+ return unless $self->connect;
}
return $self;
}
Cheers,
Stephen