Browse files

Add instructions about how to setup test database (#282)

* Add instructions about how to setup test database

* Be more explicit about the need to check .env.test file

Previous version may lead the reader to conclude that there's
something missing in environment variables for test environment where
in fact he just have to check that the existing info are matching its
database setup / credentials.
  • Loading branch information...
Bounga authored and jodosha committed Feb 28, 2017
1 parent d2fbf26 commit dd763374d9104dec4250021cbec6b96f560bbf44
Showing with 19 additions and 1 deletion.
  1. +6 −0 source/guides/command-line/
  2. +13 −1 source/guides/
@@ -25,6 +25,12 @@ With `db create` we can create the database for the current environment.
% bundle exec hanami db create
To be able to run tests, test database has to be explicitly created
% HANAMI_ENV=test bundle exec hanami db create
In order to preserve production data, this command can't be run in the production environment.
### Drop
@@ -70,7 +70,7 @@ Then we can use the new `hanami` executable to generate a new project:
<p class="notice">
By default, the project will be setup to use a SQLite database. For real-world projects, you can specify your engine:
% hanami new bookshelf --database=postgres
@@ -159,6 +159,18 @@ Note that, although Hanami is ready for a Behavior Driven Development workflow o
We'll go with [Minitest]( here (which is the default), but we can use [RSpec]( by creating the project with `--test=rspec` option.
Hanami will then generate helpers and stub files for it.
<p class="notice">
Please check .env.test in case you need to tweak the database URL.
We have to migrate our schema in the test database by running:
% HANAMI_ENV=test bundle exec db prepare
As you can see, we have set `HANAMI_ENV` environment variable to instruct our command about the environment to use.
### Following a Request
Now we have a test, we can see it fail:

0 comments on commit dd76337

Please sign in to comment.