Error Suit test mongoid

good afternoon

i started a project that has mongo as a requirement, installed Mongoid and let the generator create the file config / mongoid.yml. But I’m struggling to set up the test.

describe User do

before { @user = }

subject { @user }

it { should respond_to(:email) }

it { should respond_to(:password) }

it { should respond_to(:password_confirmation) }

it { should be_valid }

it { should validate_presence_of(:email) }

it { should validate_uniqueness_of(:email) }

it { should validate_confirmation_of(:password) }

it { should allow_value(‘’).for(:email) }


when run testing, pops up the error


  1. User should validate that :email is case-sensitively unique

Failure/Error: it { should validate_uniqueness_of(:email) }


uninitialized constant ActiveRecord

i think the mongoid is not being used in the test

the gems that i’m using are these

gem ‘mongoid’, git: ‘

group :development, :test do

gem “factory_girl_rails”

gem ‘ffaker’


group :test do

gem “rspec-rails”

gem “shoulda-matchers”, require: false


and the support/shoulda_matchers.rb

require “shoulda/matchers”

Shoulda::Matchers.configure do |config|

config.integrate do |with|

with.test_framework :rspec

with.library :rails



you could help me set up the test correctly with mongo??

thank you :slight_smile: