mongodb/mongo-ruby-driver — pull request #287 by estolfo (2013-10-21 22:17:50+00:00)
Title: Don't merge in named nil opts into command selector

This pull request solves a bunch of failures in Jenkins on 1.8.7
https://jenkins.10gen.com/job/mongo-ruby-driver-1.x-stable/16/mongodb_server=stable-release,os_arch=linux64,ruby_language_version=1.8.7-p374,test_type=with-ext/console

The problem is that if :socket => nil is passed as a command option into db#command, the nil socket was being merged into the command selector. This was because in the logic

opts[:socket] ? { :socket => opts.delete(:socket) } : {}

opts[:socket] evaluates to nil/false so the :socket => nil pair wouldn't get pruned out of opts.

I've updated the code to prune out the named opts depending on whether the opts has that key. This should avoid ending up with a selector that was causing the Jenkins failures like below:

{ :ping => 1, :socket => nil }