How to do proper database testing (TDD) on Rails 3 using MongoDB and Mongoid

后端 未结 5 2105
轻奢々
轻奢々 2021-02-04 03:02

How would go about writing proper unit testing (and integration testing for that matter) using MongoDB through Mongoid on Rails ?

I am asking, because to the opposite of

5条回答
  •  春和景丽
    2021-02-04 03:43

    Here's what I did (using Test::Unit and Mongoid 3)...

    # test/test_helper.rb
    setup {
      Mongoid.default_session.collections.select {|c| c.name !~ /system/ }.each(&:drop)
    }
    

提交回复
热议问题