Use Ruby with Travis CI

The following is a guide to getting started with Travis CI using Ruby.

Prerequisite #

To get started, create a .travis.yml file and add it to the root directory of your Ruby project.

Specify the Language and Version #

Define the Ruby version you want Travis CI to test against. The example below uses Ruby versions 2.7 and 3.0.

language: ruby
rvm:
  - 2.7
  - 3.0

Install Build Dependencies #

Install your dependencies via Bundler by using the bundle install command.

install:
  - bundle install

Define the Test Command #

Specify a command to run your tests. The example below uses RSpec:

script:
  - bundle exec rspec

Commit and Push #

Push the .travis.yml file to your repository, and Travis CI runs the tests for your Ruby project. The following is the complete example:

language: ruby
rvm:
  - 2.7
  - 3.0
install:
  - bundle install
script:
  - bundle exec rspec

Further Reading #

For more information on Ruby projects, see: