环境是 rvm、rspec 2.8.0、rails 3.0.6 和 pg 0.13.2 上的 REE(2011.12)。在 CentOS 5.6 上使用 PostgreSQL 8.3.17。db:migrate 正常工作。但是 rspec 有以下错误。
1) ApiController articles OK
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::StatementInvalid:
PG::Error: ERROR: relation "table_name" does not exist
: DELETE FROM "table_name"
我正在将我的项目从带有 rspec 1.x 系列的 rails 2.3.5 更新到带有 rspec2 的 rails 3.0。复制了所有 rspec 测试,我已经合并了旧的 spec_helper.rb 和新的(它是生成的rails g rspec:install
)。
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end
我阅读了有关此错误的类似问题。所以我尝试了rake db:test:prepare
或rake db:test:load
,但它没有解决。你有什么主意吗?看起来测试没有在测试数据库上运行......我该怎么办?:(