Environment is REE(2011.12) on rvm, rspec 2.8.0, rails 3.0.6, and pg 0.13.2. Using PostgreSQL 8.3.17 on CentOS 5.6. The db:migrate have work correctly. But rspec have got following error.
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"
I’m updating my project from rails 2.3.5 with rspec 1.x series to rails 3.0 with rspec2. Copied all rspec tests, and I have merged old spec_helper.rb and new one(It was generated 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
I read similar question about this error.So I tried rake db:test:prepare or rake db:test:load, But It’s not resolve. Do you have any idea?
It looks like the test hasn’t run on test database… How do I do? 🙁
I’ve run into this in two instances (updated 6/13/2012):
First:
I haven’t yet migrated my test database…
rake db:migrate…which you need to do before both
db:test:prepareanddb:test:load.When you invoke rspec it should
prepareandloadyour database for you anyway. You shouldn’t have to do that by hand.Second:
A typo in my migration. I accidentally reversed my table and column names in the parameter list.
A migration on a Rails 3.1 project:
…which is wrong, because
has_import_errorsandimport_data_cacheare my column names, and they therefore should come second, not first.The correct migration, with the table name first was: