Skip to content

Development

Chang Lu edited this page Apr 21, 2025 · 9 revisions

This page documents useful commands you may need when working on the Lamorinda Spirit Van project during local development, testing, and debugging.


Database Setup (Development)

Run these commands after cloning the project and installing dependencies to initialize your local database:

You can view all available Rake tasks with:

rake --tasks

All-in-one Rake task command that resets the database, runs migrations, seeds, and imports data:

rake setup:all

Standard setup commands:

# Drop the database (use only if you want to reset from scratch)
rake db:drop

# Create the database
rake db:create

# Run all migrations
rake db:migrate

# Seed with base data
rake db:seed

# Import mock address, passenger, and ride data
rake import:all

Running Tests

Use the following commands to verify that everything is working:

bundle exec rspec      # Run RSpec unit and integration tests
bundle exec cucumber   # Run Cucumber feature tests

Viewing Code Coverage

After running tests, you can open the SimpleCov HTML report locally:

macOS

open coverage/index.html

WSL / Linux

First, ensure xdg-utils is installed:

sudo apt install -y xdg-utils  # -y auto-confirms installation

Then open the report with:

xdg-open coverage/index.html

This report shows line-by-line test coverage for the codebase, including both RSpec and Cucumber tests.


Deploying to Heroku (Manual Workflow)

If you need to manually push local changes to Heroku and reinitialize the remote database, follow the steps below.

1. Log in to Heroku CLI

If this is your first time using Heroku CLI on this machine, log in via:

heroku login

This will open a browser window to authenticate your Heroku account.


2. Check your local branch and available Heroku apps

git branch --show-current   # Shows your current Git branch
heroku apps                 # Lists your Heroku apps

3. Add the Heroku remote (if not already set)

Check whether the heroku remote is configured:

git remote -v

If not, add it by replacing <your-app-name> with your actual Heroku app name:

heroku git:remote -a <your-app-name>

You should now see heroku listed as a Git remote.


4. Push local code to Heroku's main branch

Replace your-branch-name with the result of git branch --show-current:

git push heroku your-branch-name:main

Example:

git push heroku 85-feat-password-reset-emails:main

5. Reset and reinitialize the remote database

⚠️ This will delete all data in the remote Heroku PostgreSQL database:

heroku pg:reset --confirm <your-app-name>
heroku run rake db:migrate
heroku run rake db:seed
heroku run rake import:all
heroku restart

✅ Optional: Rename the Heroku remote

To simplify future command usage, you can rename the heroku remote:

git remote rename heroku my

After this, use --remote my instead of --remote heroku in all future commands.


If you are running into environment or setup issues, please refer to the Getting Started page for full setup instructions.
Before deploying to Heroku, make sure all required environment variables have been properly configured. See Environment Configuration for details.

Clone this wiki locally