Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mongo/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Client
# @return [ Hash ] options The configuration options.
attr_reader :options

# Delegate command execution to the current database.
def_delegators :@database, :command
# Delegate command and collections execution to the current database.
def_delegators :@database, :command, :collections

# Delegate subscription to monitoring.
def_delegators :@monitoring, :subscribe, :unsubscribe
Expand Down
20 changes: 20 additions & 0 deletions spec/mongo/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -742,4 +742,24 @@
expect(client.dup.options).to be_a(Mongo::Options::Redacted)
end
end

describe '#collections' do

before do
authorized_client.database[:users].create
end

after do
authorized_client.database[:users].drop
end

let(:collection) do
Mongo::Collection.new(authorized_client.database, 'users')
end

it 'refers the current database collections' do
expect(authorized_client.collections).to include(collection)
expect(authorized_client.collections).to all(be_a(Mongo::Collection))
end
end
end