On Windows I'm install RubyTest Plugging for SublimeText3.
I'm runing Vagrant with CentOS6.5 where is my Rails4 project with configured rspec.
How I can start RubyTest Plugging in SublimeText3 which run rspec tests through vagrant on virtual CentOS but not on Windows?
I'm set:
{
"ignored_directories": [".git", "vendor", "tmp"],
"run_rspec_command": "vagrant ssh --command \"'cd /vagrant/sites/sample_app && rspec spec'\""
}
It works!
But how to set for run:
1) only active test file?
2) only active line in test file?
PS It works only in SublimeText2
I've had success with a custom RubyTest command. Crafting that command depends on your individual setup, but my configuration looks like the following:
{
"ignored_directories": [ ".git", "tmp" ],
"run_rspec_command": "cd $DIR_WITH_VAGRANTFILE && vagrant ssh --command \"cd /vagrant/`echo {relative_path} | sed 's/\\/spec.*$//'` && bundle exec rspec `echo {relative_path} | sed 's,^[^/]*.*/spec,spec,'`\"",
"run_single_rspec_command": "cd DIR_WITH_VAGRANTFILE && vagrant ssh --command \"cd /vagrant/`echo {relative_path} | sed 's/\\/spec.*$//'` && bundle exec rspec `echo {relative_path} | sed 's,^[^/]*.*/spec,spec,'` -l{line_number}\"",
}
These commands makes a few assumptions.
You have an environment variable called $DIR_WITH_VAGRANTFILE
that has the path to the directory which contains your Vagrantfile
That directory is mounted at /vagrant in your VM
There are several rails apps under that directory, e.g. /vagrant/rails_app_1, /vagrant/rails_app_2
The command works by extracting the full folder path from the relative_file variable, and remotely executing bundle exec rspec
on the filename.
If you hvae a simpler setup with the rails app being directly within /vagrant, then you should be able to get away with something like the following:
{
"ignored_directories": [ ".git", "tmp" ],
"run_rspec_command": "cd $DIR_WITH_VAGRANTFILE && vagrant ssh --command \"cd /vagrant && bundle exec rspec {relative_path}\"",
"run_single_rspec_command": "cd DIR_WITH_VAGRANTFILE && vagrant ssh --command \"cd /vagrant && bundle exec rspec {relative_path} -l{line_number}\"",
}
Note: If you have multiple rails apps in different setups and different locations, you'll have to change this setup for each configuration.