Skip to content

Commit

Permalink
fixes use of DatabaseCleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
bmabey committed Nov 11, 2010
1 parent fe247b4 commit 0c924cf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

DatabaseCleaner.orm = "mongoid"

This comment has been minimized.

Copy link
@bmabey

bmabey Nov 11, 2010

Author Owner

The problem was with the string.. DatabaseCleaner needs to call #to_sym, but isn't in 0.6.0. So, it should really have been:

DatabaseCleaner.orm = :mongoid

However, even this is unneeded since DatabaseCleaner is smart enough to autodetect Mongoid.

DatabaseCleaner.strategy = :truncation

RSpec.configure do |config|

config.before(:suite) do
DatabaseCleaner[:mongoid].strategy = :truncation

This comment has been minimized.

Copy link
@bmabey

bmabey Nov 11, 2010

Author Owner

I moved this line above. Also note that I did not specify :mongoid. Since you are only using a single orm you do not need to use the [] method to indicate that :mongoid is being used. I will try to improve the documentation about this.

DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.clean

This comment has been minimized.

Copy link
@bmabey

bmabey Nov 11, 2010

Author Owner

These are equivalent at this point (since truncation has been set)... so either one would work.

end


Expand Down

0 comments on commit 0c924cf

Please sign in to comment.