Skip to content

Development

Zhixia Lin edited this page Jun 13, 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

Saving Blazer Queries

Blazer queries are stored as model records in the database, they will not persist through database drops, we made a rake script to save and import these queries:

You can save the current blazer queries to blazer_queries.yml:

rake blazer:export

You can import the saved blazer queries to the current database:

rake blazer:import

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.


Running Just the Docs

We use Just the Docs to manage the user instruction site.
If the application changes in a way that affects user behavior, the corresponding help documentation should be updated.

To run the documentation site locally, use the following commands:

cd docs
bundle exec jekyll server

The documentation is published online via GitHub Pages. We adopt the "Publishing with a custom GitHub Actions workflow" approach for deployment.


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 -i

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:

If you are using the default remote (heroku):

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

If you are using a custom remote (e.g., my):

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

✅ 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.