Prateek Papriwal
Prateek Papriwal

Reputation: 41

The rspec test fails while i am using mongodb database

I am using rspec-rails-3 and my version of rails is 4.0.2. I have mongodb database. While i am trying to run rspec tests, i am getting error

Failure/Error: ext_wiki = Entity.find_by(name_ref:'dev_extraction for wikipedia')
     Optionable::Unknown:
       :consistency is an unknown option. Valid options are: :write, :read, :database, :max_retries, :pool_size, :retry_interval, :refresh_interval, :down_interval, :ssl, :timeout, :instrumenter, :auto_discover.

I have a Entity named model. Code in entity_spec.rb is as follows -:

require 'rails_helper'

RSpec.describe Entity, :type => :model do
    it "checks old and new code" do
    ext_wiki = Entity.find_by(name_ref:'dev_extraction for wikipedia')
    ext_wiki1 = Entity.find_by(name_ref:'dev_extraction for wikipedia')
    expect(ext_wiki1['code']).to eq(ext_wiki['code'])
    end

    it "gives pass" do
    expect(1).to eq(1)
    end
end

Upvotes: 1

Views: 594

Answers (2)

will
will

Reputation: 31

Even I change consistency to :read, it didn't work. What I did is I remove the line "consistency: :strong" line from mongoid.yml

Upvotes: 1

Gergo Erdosi
Gergo Erdosi

Reputation: 42048

Your Mongoid configuration (mongoid.yml) has an option (consistency) which is not a valid option. The 4.0.0 changelog says:

The :consistency option is no longer valid, use the :read option now.

Upvotes: 4

Related Questions