無法使用database_cleaner.rb
清除數據;在運行測試時拋出以下問題。`autodetect':未檢測到已知的ORM
/Users/prashanth_sams/.rvm/gems/ruby-2.0.0-p598/gems/database_cleaner-1.3.0/lib/database_cleaner/base.rb:147:in '自動檢測':沒有已知檢測到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'
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
結帳這個博客來配置數據庫清潔器http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/ –
您是否定義了一個模型? – gnerkus