1

I'm new to Ruby on Rails and following Michael Hartls Ruby on Rails Tutorial. When I run bundle rake exec test, I am getting this error:

ERROR["test_should_get_new", SessionsControllerTest, 2.331314]
test_should_get_new#SessionsControllerTest (2.33s)
ActiveRecord::StatementInvalid:         
ActiveRecord::StatementInvalid: Could    not find table 'users'

and once similar for all of my tests. I see that my test database: test.sqlite3 is empty. My development database development.sqlite3 does have the users table in it.

I tried running the following to attempt cloning the users database to the test database, but nothing is working:

rake db:migrate:reset
rake db:migrate db:test:prepare

rake db:test:clone

rake db:test:prepare
rake db:test:load

but it's still empty. Any suggestions please?

1
  • Can you post your config/database.yml Commented Dec 21, 2015 at 0:01

2 Answers 2

1

I think you might be able to get it with:

RAILS_ENV=test rake db:migrate

Give it a try, I've had this problem before myself. I believe that

rake db:test:prepare

is deprecated. What version of ruby and rails are you using?

Sign up to request clarification or add additional context in comments.

Comments

1

I figured out a fix, although I'm still not sure why there was a problem to begin with. What I did was I took the pure Sql CREATE TABLE used to create the development table and executed it in the users table. Now everything is working fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.