Skip to content

Commit 8125e26

Browse files
committed
minor: fix prev commit
1 parent c984af4 commit 8125e26

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/mongo/collection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def find(selector={}, opts={})
169169
batch_size = opts.delete(:batch_size)
170170
timeout = (opts.delete(:timeout) == false) ? false : true
171171

172-
if !timeout
172+
if timeout == false && !block_given?
173173
raise ArgumentError, "Collection#find must be invoked with a block when timeout is disabled."
174174
end
175175

test/cursor_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ def test_timeout_options
167167
cursor = Cursor.new(@@coll, :timeout => false)
168168
assert_equal false, cursor.timeout
169169

170-
cursor = @@coll.find({}, :timeout => false)
171-
assert_equal false, cursor.timeout
170+
@@coll.find({}, :timeout => false) do |cursor|
171+
assert_equal false, cursor.timeout
172+
end
172173
end
173174

174175
def test_timeout

0 commit comments

Comments
 (0)