This section provides an overview of the configuration options available in the development environment for the gitlab-org/coming-soon project. The focus is on practical coding examples to illustrate each configuration aspect.

Configuration Options

1. Environment Variables

Environment variables can be set to customize the behavior of the application. Direct assignments in a .env file or through shell configurations can achieve this.

Example of a .env configuration:

# .env
APP_NAME="Coming Soon"
APP_URL="http://localhost:3000"
APP_ENV="development"

In your application, you can access these variables as follows:

# access environment variables
APP_NAME = ENV['APP_NAME']
APP_URL = ENV['APP_URL']

2. Configuration Files

The project might use a specific configuration file located in the project’s root directory, such as config/application.rb. This file can be modified to set defaults, or environment-specific settings.

For example, to set default settings in config/application.rb:

module ComingSoon
  class Application < Rails::Application
    config.app_name = ENV.fetch('APP_NAME', 'Default App Name')
    config.app_url = ENV.fetch('APP_URL', 'http://localhost')
    config.environment = ENV.fetch('APP_ENV', 'development')
  end
end

3. Development-Specific Settings

For development environments, you may want to enable debugging or other tools. This is usually configured in a specific environment file such as config/environments/development.rb.

Example configuration in development.rb:

Rails.application.configure do
  # Enable code reloading
  config.cache_classes = false
  
  # Show full error reports
  config.consider_all_requests_local = true

  # Use development logging level
  config.log_level = :debug
end

4. Gemfile Configuration

Certain gems are useful during development but may not be suitable for production. Modify the Gemfile to include such gems wrapped in a development block.

Example modification in Gemfile:

group :development do
  gem 'pry'
  gem 'better_errors'
end

5. Asset Pipeline

When developing, it can be helpful to configure assets for debugging or faster load times. Set options in config/environments/development.rb.

Example configuration to enable checking assets:

Rails.application.configure do
  config.assets.debug = true
  config.assets.compile = true
end

6. Testing Configuration

Setting up the testing framework often requires specific configurations. Update the files accordingly to specify testing options. Here is an example using RSpec:

# spec/rails_helper.rb
RSpec.configure do |config|
  config.expect_with :rspec do |expectations|
    expectations.syntax = :should
  end

  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end
end

7. Database Configuration

The database settings can be adjusted for the development environment in the config/database.yml file. Ensure to set the adapter and credentials appropriately.

Example database.yml for development:

development:
  adapter: postgresql
  encoding: unicode
  database: coming_soon_development
  pool: 5
  username: developer
  password: your_password

By following this guide, you will have a comprehensively configured development environment tailored to your development needs.

Source