when running rspec the db_name is nil

39 views
Skip to first unread message

FredO

unread,
May 22, 2012, 8:06:50 PM5/22/12
to Mongoid
I have been successfully using mongoid for some time time now in the
development environment.

However, when trying to run rspec test, I get the following messgae.

rspec user_spec.rb
allow_dynamic_fields is not a valid option for Mongo::Connection
yadda, yadda, yadda, (lots of invalid options listed herr)...
use_utc is not a valid option for Mongo::Connection

MONGODB [DEBUG] Logging level is currently :debug which could
negatively impact client-side performance. You should set your logging
level no lower than :info in production.

MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
F

Failures:

1) User automatically creates a new Account, when it is created with
role of User::ROLE_PRIMARY_ACCOUNT_ADMIN
Failure/Error: u = User.create firstname: 'Tom', lastname:
'Hanks', email: 'to...@gmail.com', roles:
[User::ROLE_PRIMARY_ACCOUNT_ADMIN], password: 'pass'
TypeError:
db_name must be a string or symbol # it is nil!
# ./user_spec.rb:11:in `block (2 levels) in <top (required)>'

Well fro the error messages about the invalid options, it appears that
the test code can connect to the database.

By putting a print statement in relevant rb file in the gem, I can see
that the db_name is nil.

my mongoid.yml file looks like this:

development:
host: localhost
database: cmf_development

test:
host: localhost
database: cmf_test

Any suggestions as to how to fix this?

Durran Jordan

unread,
May 23, 2012, 5:22:41 AM5/23/12
to mon...@googlegroups.com
Which version of Mongoid are you using? We addressed the config errors in 2.4.8:

https://github.com/mongoid/mongoid/issues/1800

2012/5/23 FredO <sin...@gmail.com>
Reply all
Reply to author
Forward
0 new messages