From the project folder, run bundle:
$ docker-compose run web bundle install
Build the app:
$ docker-compose build
Start the containers:
$ docker-compose up
Create and migrate the database:
$ docker-compose run web bundle exec rails db:create db:migrate
There are model specs and request specs.
$ docker-compose run web bundle exec rspec
$ docker-compose run web bundle exec guard --clear
curl --location --request POST 'localhost:3000/api/v1/games.json' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Lucía",
"move": "paper"
}'
{
"name": "Lucía",
"move": "paper"
}
{
"moves": [
{
"name": "Lucía",
"move": "paper"
},
{
"name": "Bot",
"move": "rock"
}
],
"result": "Lucía wins",
"created_at": "2021-05-03 15:24:06 UTC"
}
curl --location --request GET 'localhost:3000/api/v1/games.json'
{
"data": [
{
"moves": [
{
"name": "Lucía",
"move": "paper"
},
{
"name": "Bot",
"move": "rock"
}
],
"result": "Luci wins",
"created_at": "2021-05-01 17:40:52 UTC"
},
{
"moves": [
{
"name": "John",
"move": "paper"
},
{
"name": "Bot",
"move": "rock"
}
],
"result": "John wins",
"created_at": "2021-05-02 18:18:25 UTC"
},
{
"moves": [
{
"name": "John",
"move": "scissors"
},
{
"name": "Bot",
"move": "rock"
}
],
"result": "Bot wins",
"created_at": "2021-05-02 18:18:31 UTC"
},
[...]
{
"moves": [
{
"name": "Megan",
"move": "paper"
},
{
"name": "Bot",
"move": "scissors"
}
],
"result": "Bot wins",
"created_at": "2021-05-02 18:26:40 UTC"
}
],
"meta": {
"total_games": 62
},
"links": {
"first_url": "http://localhost:3000/api/v1/games.json?page=1",
"prev_url": "http://localhost:3000/api/v1/games.json?page=",
"page_url": "http://localhost:3000/api/v1/games.json?page=1",
"next_url": "http://localhost:3000/api/v1/games.json?page=2",
"last_url": "http://localhost:3000/api/v1/games.json?page=4"
}
}