gpt4 book ai didi

ruby-on-rails - `autodetect' : No known ORM was detected

转载 作者:数据小太阳 更新时间:2023-10-29 06:44:26 27 4
gpt4 key购买 nike

无法使用database_cleaner.rb 清理数据;在运行测试时抛出以下问题。

/Users/prashanth_sams/.rvm/gems/ruby-2.0.0-p598/gems/database_cleaner-1.3.0/lib/database_cleaner/base.rb:147:in `autodetect': No known ORM was detected! Is ActiveRecord, DataMapper, Sequel, MongoMapper, Mongoid, Moped, or CouchPotato, Redis or Ohm loaded? (DatabaseCleaner::NoORMDetected)

enter image description here

spec_helper.rb

ENV["RAILS_ENV"] ||= 'test'

require File.expand_path("../config/environment", __FILE__)
require 'rspec/rails'

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|

config.mock_with :rspec

config.use_transactional_fixtures = false


config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.color = true

Selenium::Application.reload_routes!

end

database_cleaner.rb

require 'database_cleaner'

DatabaseCleaner.strategy = :truncation

RSpec.configure do |config|
config.use_transactional_fixtures = false
config.before :each do
DatabaseCleaner.start
end
config.after :each do
DatabaseCleaner.clean
end
end

最佳答案

我在 controller_spec 上遇到了同样的问题。'autodetect':未检测到已知的 ORM!是否加载了 ActiveRecord、DataMapper、Sequel、MongoMapper、Mongoid、Moped 或 CouchPotato、Redis 或 Ohm? (DatabaseCleaner::NoORMDetected)

我通过在 Controller 规范上要求 rails_helper 文件来解决。

require 'rails_helper'

在 rails_helper.rb 中需要文件“database_cleaner”。

require 'database_cleaner'

关于ruby-on-rails - `autodetect' : No known ORM was detected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30168421/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com