Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit e1d4e84

Browse files
authored
Add docker-compose.yml for easy testing (mirego#70)
1 parent 47f6627 commit e1d4e84

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ user.errors.full_messages
164164
# ]
165165
```
166166

167+
## Development
168+
169+
The tests require a database. We've provided a simple `docker-compose.yml` that will make
170+
it trivial to run the tests against PostgreSQL. Simply run `docker compose up -d`
171+
followed by `rake spec`. When you're done, run `docker compose down` to stop the database.
172+
173+
In order to use another database, simply define the `DATABASE_URL` environment variable
174+
appropriately.
175+
167176
## License
168177

169178
`ActiveRecord::JSONValidator` is © 2013-2022 [Mirego](https://www.mirego.com) and may be freely distributed under the [New BSD license](https://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/activerecord_json_validator/blob/master/LICENSE.md) file.

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.2'
2+
3+
services:
4+
postgres:
5+
image: postgres:10
6+
ports:
7+
- 5432:5432
8+
restart: on-failure
9+
environment:
10+
POSTGRES_DB: activerecord_json_validator_test
11+
POSTGRES_HOST_AUTH_METHOD: trust # don't require password

spec/support/macros/database/database_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ def initialize(opts = {})
66
end
77

88
def establish_connection!
9-
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
9+
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL', 'postgres://postgres@localhost/activerecord_json_validator_test'))
1010
end
1111
end

0 commit comments

Comments
 (0)