I've searched a lot, but could not find any similar problem to mine. Suppose we've got namespaced models, UserManagement::User
and UserManagement::Session
.
Here are factories for theses models:
FactoryGirl.define do
factory :user, class: UserManagement::User do
UserManagement::User.set_database_name 'db_name'
id '000000000a00a000a0000001'
login 'Mark'
password 'password'
password_confirmation 'password'
data { {} }
session { build(:session) }
initialize_with { new(attributes) }
end
end
and
FactoryGirl.define do
factory :session, class: UserManagement::Session do
token '0000-0000-0000'
expiration { Time.zone.now + 30.minutes }
end
end
When I perform FactoryGirl.lint
, I am receiving user - uninitialized constant Session (NameError)
which is, as I guess, problem with namespacing, because :user
factory tries to look for Session
model and not for UserManagement::Sesssion
.
Okay, so I found out solution of that problem. As I guess MongoMapper isn't very module - friendly, as ActiveRecord. I had to explicitly define which class name my Session association is, even if it is in the same module scope. So the solution is one :session, class_name: 'UserManagement::Session' Thanks everyone for any help!