test/unit/user_test.rb holds:
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
And executing:
perrys-MacBook-Pro:iway perry_mac$ ruby -Itest test/unit/user_test.rb
Yields the following:
Loaded suite test/unit/user_test
Started
E
Finished in 0.006410 seconds.
1) Error:
test_the_truth(UserTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: user_sessions: DELETE FROM "user_sessions" WHERE 1=1
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/sqlite_adapter.rb:135:in `execute'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:288:in `update_sql'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/sqlite_adapter.rb:139:in `update_sql'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:293:in `delete_sql'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/sqlite_adapter.rb:145:in `delete_sql'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:54:in `delete'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/query_cache.rb:16:in `delete'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:569:in `delete_existing_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:531:in `block (4 levels) in create_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:531:in `each'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:531:in `block (3 levels) in create_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:530:in `block (2 levels) in create_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract_adapter.rb:109:in `disable_referential_integrity'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:521:in `block in create_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.9/lib/active_support/benchmarkable.rb:55:in `silence'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:520:in `create_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:979:in `load_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:944:in `setup_fixtures'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:415:in `_run_setup_callbacks'
/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.9/lib/active_support/testing/setup_and_teardown.rb:34:in `run'
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
The error statement comments on an SQL DELETE query, which seems bizarre. And why is it even referencing user_sessions here? This test used to pass. After some db migrations (adding columns to existing tables) it does not. Can someone help me bridge my understanding gap here? Is there some mysterious entity that I have to reload. I tried each of:
rake db:test:clone
rake db:test:clone_structure
rake db:test:load
rake db:test:prepare
rake db:test:purge
… but still see the same output. I can drop my current git branch and start over, but I’d really like to understand what tripped me up first. Please indicate if there is a log or other source of info I should be looking at to untangle the problem.
ADDENDUM (schema.rb):
ActiveRecord::Schema.define(:version => 20110901142600) do
create_table "users", :force => true do |t|
t.string "username"
t.string "email"
t.string "crypted_password"
t.string "password_salt"
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "last_request_at"
t.datetime "current_login_at"
t.datetime "last_login_at"
t.string "current_login_ip"
t.string "last_login_ip"
end
end
I think the key is in the 10th line of the stack trace:
Notice
fixtures.rbanddelete_existing_fixtures. Rails cleans all the fixtures out of the database before running your test suite. Do you have auser_sessions.ymlfile intest/fixtures?