Rails database setup on Travis-CI

后端 未结 3 980
执笔经年
执笔经年 2021-01-30 23:02

I\'m trying to use Travis Continuous Integration on a Rails project. The documentation says that the test db must be configured as following for SQLite3:

test:
          


        
3条回答
  •  别那么骄傲
    2021-01-30 23:31

    @mrm's blog post doesn't say anything about answering your question. I faced the same problem where my postgreql credentials are different on my local machine than travis default. This is the simplest solution I came up with:

    # config/database.yml
    test:
      adapter: postgresql
      database: medscraper_test
      username: <%= ENV['TRAVIS'] ? 'postgres' : 'MY_TEST_USERNAME' %>
      password: <%= ENV['TRAVIS'] ? '' : 'MY_TEST_PASSWORD' %>
    

    Note that Travis CI automatically sets TRAVIS environment variable. Your solution would be:

    # config/database.yml
    test:
      adapter: sqlite3
      database: <%= ENV['TRAVIS'] ? '":memory:"' : 'db/test.sqlite3' %>
      timeout: 500
    

提交回复
热议问题