2

The error below is displayed when $ rspec is executed:

No known ORM was detected! Is ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, Moped, or CouchPotato, Redis or Ohm loaded? (DatabaseCleaner::NoORMDetected)

This is a snippet from the spec_helper.rb file:

config.before(:suite) do
  DatabaseCleaner.strategy = :transaction
  DatabaseCleaner.clean_with(:truncation)
end

The Rails application in question uses ActiveRecord as the ORM and the documentation for Database Cleaner states that it checks for ActiveRecord first.

The Rails version for the application is 5.0.0.beta2.

What is the cause of the error and how can this be fixed?

4

1 回答 1

2

原因:

该错误是由缺少模型引起的。因为没有模型,所以应用程序没有指定ORM。因此,DatabaseCleaner无法选择合适的策略。

解决方案

至少应创建一个模型。这可以通过rails generate scaffoldorrails generate model命令完成。

于 2016-02-08T23:10:36.563 回答