Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2340

When using with ActiveRecord, Mongoid gem in the Gemfile disables db:test:prepare in default rake task

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.6
    • Affects Version/s: None
    • Component/s: None
    • None

      When you put 'mongoid' gem v.3.0.5 in your gemfile (to use it along with ActiveRecord),

      #Gemfile
      gem 'mongoid', '3.0.5'
      gem 'rspec-rails', group:test
      

      you can not run rspec tests, coz they doesn't recreate your database:

      $ rake --trace -n
      #no rake db:test:prepare in the output
      

      possible workaround :

      #Gemfile
      gem 'mongoid', '3.0.5', require:false
      gem 'rspec-rails', group:test
      
      #config/application.rb
      require 'mongoid' # or require 'mongoid/railtie'
      require 'rails'
      
      $ rake --trace -n
      #db:test:prepare is in the output
      

      Line that changes this behaviour is in the lib/mongoid/railtie.rb

      config.send(generator).orm :mongoid, migration: false
      

      Can't say more if it's desired behaviour, or how it can be corrected (

            Assignee:
            Unassigned Unassigned
            Reporter:
            altV altV [X]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: