Add instructions about how to setup test database (
* 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
2 changed files
and 1 deletion.
@@ -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.
@@ -70,7 +70,7 @@ Then we can use the new `hanami` executable to generate a new project:
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](https://github.com/seattlerb/minitest) here (which is the default), but we can use [ RSpec](http://rspec.info) by creating the project with `--test=rspec` option.
Hanami will then generate helpers and stub files for it.
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: