Search code examples
ruby-on-railsunit-testingrubymine

ActiveRecord::StatementInvalid: Could not find table


I am trying to run users_test.rb file which just has

test "the truth" do
     assert true
   end

I do have a likes table, still I am getting this error. Why so?

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
➜  channelappnew  rake db:test:clone
➜  channelappnew  rake db:test:clone_structure
➜  channelappnew  rake db:migrate
➜  channelappnew  rake db:test:load
➜  channelappnew  rake db:test:prepare
➜  channelappnew  rake db:test:purge
➜  channelappnew  ruby -Itest test/unit/user_test.rb
Loaded suite test/unit/user_test
Started
E

Error:
test_the_truth(UserTest):
ActiveRecord::StatementInvalid: Could not find table 'likes'




Finished in 0.058371 seconds.

1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed

17.13 tests/s, 0.00 assertions/s

Thanks!


Solution

  • before test do rake db:test:prepare