【发布时间】:2015-09-10 09:53:26
【问题描述】:
我在执行代码时收到以下错误。
未检测到已知的 ORM!是否加载了 ActiveRecord、DataMapper、Sequel、MongoMapper、Mongoid、Moped 或 CouchPotato、Redis 或 Ohm? (DatabaseCleaner::NoORMDetected)
任何人都可以为此提出解决方案。
spec_helper.rb:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/database_cleaner.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :mocha
config.before(:each) do
DatabaseCleaner.clean
#Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop) # transactional fixtures hack for mongo
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
config.use_transactional_fixtures = false
end
【问题讨论】:
-
你定义模型了吗?
标签: ruby-on-rails ruby database rspec