Skip to content
Lucas edited this page Sep 25, 2020 · 17 revisions

Using docker for development

Use the sample file config/database.yml.docker, like this:

$ cp config/database.yml.docker config/database.yml

Use the settings.yml and secrets.yml file samples contained in config:

$ cp config/settings.yml.example config/settings.yml
$ cp config/secrets.yml.example config/secrets.yml

Install the latest docker and docker-compose versions for your system. Then run:

$ docker-compose up

Docker env variables

RAILS_ENV

Todo: Only run using docker in development mode for now

DEVISE_SECRET_KEY

Next you'll only need to create the database with:

$ docker exec -it musical-artifacts_web_1 bundle exec rake db:create

Now the app will be running in localhost:3000

Using the old method on a Linux system

Setting up a development environment

This application is developed in Ubuntu, so these instructions apply to most Debian based distros. Feel free to edit it to add extra considerations for other environments.

Dependencies

rails4.2 ruby2.4.2 postrgresql >= 9.3 postrgresql-contrib >= 9.3

Install dependencies via apt-get:

$ sudo apt-get install postgresql-server-dev-9.3 postgresql-contrib-9.3 \
  git-core zlib1g-dev build-essential libreadline-dev libssl-dev curl nodejs \
  redis-server awesfx 

Install Ruby 2.4.2

I recommend installing rbenv, with the optional step to install ruby-build. Then install ruby 2.4.2 like:

$ rbenv install 2.4.2

Checkout the project's code and install gems

$ git clone https://github.com/lfzawacki/musical-artifacts.git

Then go into the project directory and type, this may take some time:

$ gem install bundle
$ bundle install

Create and seed the database

First copy the example settings file:

cp config/settings.yml.example config/settings.yml

Then create a postgres user and give him permission for development and testing databases (using password and usernames defined in config/database.yml):

$ sudo su - postgres
$ psql -c "create user musical_artifacts with password 'musical_artifacts';"
$ psql -c "create database musical_artifacts_development owner musical_artifacts;"
$ psql -c "create database musical_artifacts_test owner musical_artifacts;"
$ psql -c "alter role musical_artifacts createrole createdb;"
$ psql template1 -c "create extension hstore;"

Don't forget to set local access permissions to trust in pg_hba.conf ( see here)

Then, let's create the database and seed it:

bundle exec rake db:create
bundle exec rake db:reset

Run the server

bundle exec rails s

Running tests

First prepare the database:

bundle exec rake db:reset RAILS_ENV=test

To run tests type:

bundle exec rake

To run a single test file:

bundle exec m test/controllers/artifacts_controller_test.rb

Or to run a single assertion, for example on line 35:

bundle exec m test/controllers/artifacts_controller_test.rb:35

Before sending a patch or pull request remember to run the tests and add new ones.

Tests live inside the tests/ directory and use the minitest and capybara frameworks.