This app was built while learning TDD from Test-Driven Rails tutorial on Upcase.
But I soon felt an urge for using the BDD's outside-in approach and I decided to include Cucumber in the picture along with Capybara and RSpec.
Also, it uses the latest version of Ruby (v3) and Rails (v7) at the time.
This app is deployed on a free Render tier which spins down the server if it's idle for 15 minutes, so it takes some time to spin up the server again when it next receives a request.
Demo URL: https://todoer-9s1j.onrender.com/
-
Install PostgreSQL database
-
Install
libpq
library to successfully installpg
gem$ sudo apt install libpq-dev
-
Setup rbenv for easily managing multiple Ruby versions
To setup this project, you'll want to clone and run the setup script for the repo.
$ git clone [email protected]:ammarshah/todoer.git
$ cd todoer
$ rbenv install
$ cp .env.template .env
$ bin/setup
Run RSpec tests:
# By default, it runs tests in a random order
$ bundle exec rspec
# Use --seed option if you want to run tests with seed
$ bundle exec rspec --seed=YOUR_SEED
# For debugging specs order dependency
# use --bisect option to get the minimum
# number of tests to run to reproduce the failure
$ bundle exec rspec --bisect --seed=YOUR_SEED
Run Cucumber tests:
# By default, it runs tests in a random order
$ bundle exec cucumber
# Use --order option if you want to run tests with seed
$ bundle exec cucumber --order=random:YOUR_SEED
Run all tests:
$ bin/rake
a. Build the image:
$ docker compose build
b. Tag the image with new build version:
$ docker tag ammarshah/todoer-server:latest ammarshah/todoer-server:1.0.0
c. Push the tag to your Docker Hub repository:
$ docker push ammarshah/todoer-server:1.0.0
$ docker push ammarshah/todoer-server:latest
d. Commit and push the latest code to your GitHub repository:
$ git push origin master
e. Login to your production server via ssh and pull the latest code from GitHub repository:
$ git pull origin master
f. Finally, use docker compose
command to run the required services:
$ docker compose up -d
Note: This will pull the latest (pre-built) image for each service, listed in compose.yml
, from the Docker Hub registry and run the containers.
The application is accessible at http://your-server-ip.