#
Verify Configuration Locally
Before pushing to GitHub, validate your configuration locally on a virtual machine running Ubuntu 22.04 LTS.
These commands assume your development environment runs on MacOS and uses homebrew as a package manager.
#
1. Start Vagrant virtual machine
From the root of project directory, create and log in to a virtual machine. Firstly, install vagrant on your local machine.
brew install virtualbox vagrant
touch Vagrantfile
Then, create Vagrantfile
to configure your virtual machine from the example
below.
Vagrant.configure("2") do |config|
config.vm.box = "turbotest/ubuntu_2204_LTS"
config.vm.provider "virtualbox" do |vb|
vb.cpus = 4
vb.memory = "5120"
end
end
Next, create the virtual machine running Ubuntu 22.04 LTS and log in with these commands:
# Don't forget to run these commands from the root of your project directory
# cd $REPOSITORY_LOCAL_DIRECTORY
vagrant up
vagrant ssh
#
2. Verify base_image
and before_test_run
commands
Then, inside the virtual machine, verify the base_image and before_test_run commands. You can copy the commands from your .turbo_test.toml
file or the above sample configurations. For example:
[base_image]
commands = '''
sudo apt update -y
sudo apt-get install cmake -y
'''
[before_test_run]
commands = '''
sudo systemctl start postgresql@16-main.service
bundle install
'''
Don't forget to set environment variables.
Any environment variables set in the .turbo_test.toml env configuration should also be set in the vagrant virtual machine.
# Change to project root directory mounted from host
cd /vagrant
# Set environment variables from .turbo_test.toml env configuration
export RAILS_ENV=test
# Execute base_image commands
sudo apt update -y
sudo apt-get install cmake -y
# Execute before_test_run commands
sudo systemctl start postgresql@16-main.service
bundle install
#
3. Verify unit test execution
Now, you should be able to execute a unit test after your base_image and before_test_run commands complete successfully.
For example, from the following configuration file:
[test_run.default]
command = "bundle exec rails test"
files = ["test/**/*_test.rb"]
Execute this unit test:
bundle exec rails test test/models/user_test.rb
#
4. Verify test_run
test file glob
Lastly, check the UNIX file glob for your test runs. Give the following configuration file:
[test_run.default]
command = "bundle exec rails test"
files = ["test/**/*_test.rb"]
The output of this command should be a list of all your test files.
cd /vagrant
ls -1 test/**/*_test.rb
After successfully validating your configuration locally, verify your configuration on TURBO TEST.