Error Suit test mongoid

5 views
Skip to first unread message

Vinicius Luiz

unread,
Sep 16, 2016, 3:22:57 AM9/16/16
to Ruby on Rails: Talk
# 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 = FactoryGirl.build(: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('example@domain.com').for(:email) }
end

# when run testing, pops up the error

Failures:

  1) User should validate that :email is case-sensitively unique
     Failure/Error: it { should validate_uniqueness_of(:email) }

     NameError:
       uninitialized constant ActiveRecord

# i think the mongoid is not being used in the test
# the gems that i'm using are these


group :development, :test do
  gem "factory_girl_rails"
  gem 'ffaker'
end

group :test do
  gem "rspec-rails"
  gem "shoulda-matchers", require: false
end

# 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
  end
end

you could help me set up the test correctly with mongo??
thank you :)
Reply all
Reply to author
Forward
0 new messages