> On Sep 10, 2017, at 2:33 PM, Ben Edwards <
lo...@funkytwig.com> wrote:
>
> Thanks for your reply,
>
> I think I can work out most of the stuff but its the cloning the dev (db) into test that I cant work out. Seem to remember it saying something in the ruby config about the test database being re-writern from development (not sure how/when)
If you have written migrations as you go, then the test database can be created and structured by calling the following two rake commands:
rake db:create RAILS_ENV=test
rake db:migrate RAILS_ENV=test
If you have any seeds, then follow those with:
rake db:seed RAILS_ENV=test
I believe there are additional rake tasks specific to test setup that may condense all of the above into a one-liner, you can see the entire list of rake tasks by issuing this command (from within your rails project directory:
rake -T
Your tests should not rely on any data besides what you add using seeds or fixtures, as the test database may (should) be emptied and re-initialized multiple times during a single testing run. So your comment about "cloning" the dev DB into test may indicate that you need some more information about how Rails tests run in general than you have at present.
A good first stop is here:
http://guides.rubyonrails.org/testing.html and if you haven't done so already, you should definitely take a couple of days to work all the way through
https://railstutorial.org which is free to use online. If you haven't gone through this tutorial in the last two years, you should probably do it again, too. I've been using Rails since version 1, and I learned a few things the last time I went through it. Hands-down, it is probably the best-written technical training material I have ever used.
Walter
> To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/d706c6f4-2550-4c1f-a00e-a3f0ddaf8485%40googlegroups.com.