Check to see if Homebrew is installed by running which brew
in a terminal. If already
installed you'll get output similar to /usr/local/bin/brew
, otherwise the command will return brew not found
.
If Homebrew is already installed, update it by running brew update
.
If Homebrew is not already installed, run
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
to install it.
Run brew install rbenv
to install the latest version of rbenv.
Run rbenv init
, which will run some commands to allow rbenv
to work with zsh
, like updating the path.
Add eval "$(rbenv init -)"
to your ~/.zshrc
profile.
Run brew install postgres
to install the latest version of PostgreSQL.
We specify a recommended version of Ruby in the .ruby-version
file in funding-frontend.
To install this recommended version of Ruby, use rbenv by running rbenv install x.y.z
inside the application
directory (where x.y.z
is replaced with the version number specified in .ruby-version
).
You may need to run rbenv global x.y.z
to switch your terminal to use the new version.
Download and install Postgres.app.
Run the Postgres app.
Create an empty .env
file in your application directory by running touch .env
in a terminal.
The necessary environment variables in order to run the application are stored in the team's shared 1Password vault. If you don't have access to the shared 1Password vault, contact @stuartmccoll or @ptrelease.
With access to the vault, copy the contents of funding-frontend.env
into your own .env
file.
Install the PostgreSQL Gem, telling it the path of PostgreSQL. If PostgreSQL is installed in a default location, the command will look like:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
Run gem install bundler
to install Bundler.
Run brew install yarn
to install Yarn.
Run bundle install
to install the Ruby dependencies necessary for the application to run. These are
specified in the application's Gemfile
.
Run yarn install
to install the Yarn dependencies necessary for the application to run. These are
specified in the application's package.json
and yarn.lock
files.
Run bundle exec rails db:setup
in your terminal. If the database needs creating, run
psql
then create database funding_frontend_development;
.
Run bundle exec rails server
(or bundle exec rails s
for a shorter command) in your terminal.
The application will now be running locally and can be accessed by navigating to
https://localhost:3000
in your browser.
Server-side code is tested using RSpec.
To run the RSpec test suite, run bundle exec rspec
in your terminal.
Client-side code is tested using Jest.
To run the Jest test suite, run yarn jest
in your terminal.
Addresses are cached after searching by postcode so that they can be referred to later in the user journey.
By default, Ruby-on-Rails in development mode runs with caching disabled. In order to see caching work in
development, run bundle exec rails dev:cache
in your terminal.
Some elements of functionality are sat behind feature flags, which have been implemented using Flipper.
To toggle functionality, a Flipper needs to exist. Flipper rows exist within the flipper_features
and
flipper_gates
tables on the database. The flipper_gates
are populated with a database migration.
The flipper_features
are populated at app runtime, provided rows exist in flipper.rb
.
Update a flipper_gates
row by running a SQL statement such as (after running
psql funding_frontend_development
in your terminal to connect to the database):
UPDATE flipper_gates SET value = true WHERE feature_key = '<key_name>';