正在测试的Rails:数据库配置未指定适配器生产

时间:2015-06-03 08:10:39

标签: mysql ruby-on-rails rspec

rails 3.2.18
mysql2 0.3.18

尝试启动catch (Throwable t)
得到了很多:

rspec spec

* database.yml

19) Reports::TaxReportService  should properly generate for rests
     Failure/Error: Unable to find matching line from backtrace
     ActiveRecord::AdapterNotSpecified:
       database configuration does not specify adapter
     # /home/drobazko/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.18/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection'
     # /home/drobazko/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.18/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
     # /home/drobazko/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.18/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
     # /home/drobazko/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.2.18/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
     # ./spec/support/database_cleaner.rb:18:in `block (2 levels) in <top (required)>'

在开发过程中一切正常。

2 个答案:

答案 0 :(得分:0)

可能出现的问题:

Rails环境区分大小写。要么是database.yml中的'Test',要么运行测试为“RAILS_ENV = Test”

答案 1 :(得分:0)

尝试跑步:

rake db:test:prepare 

这将设置运行测试用例所需的测试数据库。